public static X509ExtendedKeyManager createDefaultX509KeyManager(KeyStore keystore, char[] password) {
        try {
            KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
            keyManagerFactory.init(keystore, password);
            KeyManager[] keyManagers = keyManagerFactory.getKeyManagers();
            return Arrays.stream(keyManagers)
                    .filter(manager -> manager instanceof X509ExtendedKeyManager)
                    .map(X509ExtendedKeyManager.class::cast)
                    .findFirst()
                    .orElseThrow(() -> new RuntimeException("No X509ExtendedKeyManager in " + List.of(keyManagers)));
        } catch (GeneralSecurityException e) {
            throw new RuntimeException(e);
        }
    }
Utility methods for constructing {@link X509ExtendedKeyManager}.

@author bjorncs
security-utils/src/main/java/com/yahoo/security/KeyManagerUtils.java