public static SSLSessionStrategy build(String trustStore,
            String trustStorePassword,
            String keyStore,
            String keyStorePassword,
            String[] keyAliases,
            String keyPassword,
            String[] allowedProtocols,
            String[] allowedCiphers,
            boolean allowAnyHostname,
            boolean trustSelfSigned)

    throws NoSuchAlgorithmException, KeyStoreException, CertificateException, IOException,
            KeyManagementException, UnrecoverableKeyException {

        Args.notNull(allowedProtocols, "Allowed protocols"); //$NON-NLS-1$
        Args.notNull(allowedCiphers, "Allowed ciphers"); //$NON-NLS-1$

        TrustStrategy trustStrategy = trustSelfSigned ?  SELF_SIGNED : null;
        HostnameVerifier hostnameVerifier = allowAnyHostname ? ALLOW_ANY :
            SSLConnectionSocketFactory.getDefaultHostnameVerifier();
        PrivateKeyStrategy privateKeyStrategy = keyAliases == null ? null : new SelectByAlias(keyAliases);
        boolean clientAuth = keyStore != null;

        SSLContextBuilder builder = SSLContexts.custom();

        if (trustStore != null) {
            loadTrustMaterial(builder,
                    new File(trustStore),
                    trustStorePassword.toCharArray(),
                    trustStrategy);
        }

        if (keyStore != null) {
            char[] ksp = keyStorePassword == null ? null : keyStorePassword.toCharArray();
            char[] kp = keyPassword == null ? null : keyPassword.toCharArray();
            loadKeyMaterial(builder, new File(keyStore), ksp, kp, privateKeyStrategy);
        }

        SSLContext sslContext = builder.build();
        return new SSLSessionStrategy(hostnameVerifier, new CipherSelectingSSLSocketFactory(
                sslContext.getSocketFactory(), allowedCiphers, allowedProtocols, clientAuth));
    }
Build an {@link SSLSessionStrategy}.

@param trustStore the trust store
@param trustStorePassword the truststore password (if any)
@param keyStore the keystore
@param keyStorePassword the keystore password (if any)
@param keyAliases the key aliases that are candidates for use (if any)
@param keyPassword the key password (if any)
@param allowedProtocols the allowed transport protocols.
           <strong><em>Avoid specifying insecure protocols</em></strong>
@param allowedCiphers allowed crypto ciphersuites, <tt>null</tt> to use system defaults
@param trustSelfSigned true if self signed certificates can be trusted.
            <strong><em>Use with caution</em></strong>
@param allowAnyHostname true if any hostname can be connected to (i.e. does not need to match
           certificate hostname). <strong><em>Do not use in production</em></strong>
@return the connection socket factory
@throws NoSuchAlgorithmException if the selected algorithm is not available on the system
@throws KeyStoreException if there was a problem with the keystore
@throws CertificateException if there was a problem with the certificate
@throws IOException if the truststore could not be found or was invalid
@throws KeyManagementException if there is a problem with keys
@throws UnrecoverableKeyException if the key cannot be recovered
gateway/platforms/servlet/src/main/java/io/apiman/gateway/platforms/servlet/connectors/ssl/SSLSessionStrategyFactory.java