class SSLKeyStoreLoader {

    static KeyManager[] fromPemKeyFile(Path key, Path certificate) throws IOException, GeneralSecurityException {

        final PKCS8EncodedKeySpec encodedKeySpec = getEncodedKeySpec(key);

        final KeyFactory keyFactory = KeyFactory.getInstance("RSA");
        final PrivateKey privateKey = keyFactory.generatePrivate(encodedKeySpec);

        final List<X509Certificate> certificates = getCertificates(certificate);

        KeyStore keyStore = KeyStore.getInstance(KEYSTORE_TYPE);
        keyStore.load(null, null);
        keyStore.setKeyEntry(ALIAS, privateKey, EMPTY_PASSWORD, certificates.stream().toArray(Certificate[]::new));

        final KeyManagerFactory keyManagerFactory =
                KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
        keyManagerFactory.init(keyStore, EMPTY_PASSWORD);

        return keyManagerFactory.getKeyManagers();
    }

    private  SSLKeyStoreLoader();

}