class SecurityUtils {

    public static Key loadKey(HttpsConfig config) {
        if (config.getKeyStore() != null) {
            try {
                KeyStore ks = loadKeyStore(config);
                char[] keyPasswordInChars = config.getKeyPassword();
                final Key key;
                if (config.getKeyAlias() != null) {
                    key = ks.getKey(config.getKeyAlias(), keyPasswordInChars);
                } else {
                    key = findFirstSecretKey(ks, keyPasswordInChars);
                }
                return key;
            } catch (NoSuchAlgorithmException | KeyStoreException | CertificateException | IOException
                | UnrecoverableKeyException e) {
                apimlLog.log("org.zowe.apiml.common.errorLoadingSecretKey", e.getMessage());
                throw new HttpsConfigError(e.getMessage(), e,
                    HttpsConfigError.ErrorCode.HTTP_CLIENT_INITIALIZATION_FAILED, config);
            }
        }
        return null;
    }

}