public static X509Info x509FromKeyStore(KeyStore keyStore, String password) {

        try {

            char[] pwchars = password.toCharArray();

            X509Certificate cert = null;
            Key key = null;

            Enumeration<String> aliases;
            aliases = keyStore.aliases();
            while (aliases.hasMoreElements()) {
                String alias = aliases.nextElement();

                key = keyStore.getKey(alias, pwchars);

                if (key instanceof PrivateKey) {
                    cert = (X509Certificate) keyStore.getCertificate(alias);
                }
            }

            return new X509Info(cert, (PrivateKey) key);

        } catch (KeyStoreException e) {
            throw new RuntimeException(e);
        } catch (UnrecoverableKeyException e) {
            throw new RuntimeException(e);
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException(e);
        }

    }