public static SSLContext createSslContext(ApiClientConfiguration configuration, SslStoreBundle sslStoreBundle)
        throws SslFactoryException {
    try {
        KeyManagerFactory keyManagerFactory =
                KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
        keyManagerFactory.init(sslStoreBundle.getKeyStore(), sslStoreBundle.getKeyStorePassword());

        TrustManagerFactory trustManagerFactory =
                TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
        trustManagerFactory.init(sslStoreBundle.getTrustStore());

        SSLContext sslContext = SSLContext.getInstance(configuration.getSslProtocol());
        sslContext.init(
                keyManagerFactory.getKeyManagers(), trustManagerFactory.getTrustManagers(), new SecureRandom());

        return sslContext;
    } catch (KeyStoreException
             | NoSuchAlgorithmException
             | UnrecoverableKeyException
             | KeyManagementException exception) {
        throw new SslFactoryException("Could not create Ssl context.", exception);
    }
}
