public synchronized SslContextFactory.Server getSslContextFactory()
    {
        if ( sslContextFactory != null )
        {
            return sslContextFactory;
        }

        Log.info( "Creating new SslContextFactory instance" );
        try
        {
            sslContextFactory = new SslContextFactory.Server();

            sslContextFactory.setTrustStore( configuration.getTrustStore().getStore() );
            sslContextFactory.setTrustStorePassword( new String( configuration.getTrustStore().getConfiguration().getPassword() ) );

            sslContextFactory.setKeyStore( configuration.getIdentityStore().getStore() );
            sslContextFactory.setKeyStorePassword( new String( configuration.getIdentityStore().getConfiguration().getPassword() ) );

            // Configure protocol support
            final Set<String> protocols = configuration.getEncryptionProtocols();
            if ( !protocols.isEmpty() )
            {
                // Note that this is always server-mode, so may support SSLv2Hello.
                sslContextFactory.setIncludeProtocols(protocols.toArray(new String[protocols.size()]));
            }

            // Configure cipher suite support.
            final Set<String> cipherSuites = configuration.getEncryptionCipherSuites();
            if ( !cipherSuites.isEmpty() )
            {
                sslContextFactory.setIncludeCipherSuites( cipherSuites.toArray( new String[ cipherSuites.size() ] ) );
            }

            // Set policy for checking client certificates.
            switch ( configuration.getClientAuth() )
            {
                case disabled:
                    sslContextFactory.setNeedClientAuth( false );
                    sslContextFactory.setWantClientAuth( false );
                    break;
                case wanted:
                    sslContextFactory.setNeedClientAuth( false );
                    sslContextFactory.setWantClientAuth( true );
                    break;
                case needed:
                    sslContextFactory.setNeedClientAuth( true );
                    break;
            }

            sslContextFactory.setSniRequired(SNI_ENABLED.getValue());

            return sslContextFactory;
        }
        catch ( RuntimeException ex )
        {
            // Allow initialization to restart upon next iteration.
            sslContextFactory = null;
            throw ex;
        }
    }
Creates an SSL Engine that is configured to use client mode when handshaking.

For Openfire, an engine of this mode is typically used when the server tries to connect to another server.

These SSLEngines never send SSLV2 ClientHello messages.

@return An initialized SSLEngine instance (never null).
@throws UnrecoverableKeyException if the key could not be recovered
@throws NoSuchAlgorithmException if the algorithm is not supported
@throws KeyStoreException if there was a problem accessing the keystore
@throws KeyManagementException if there was problem manging the ket
xmppserver/src/main/java/org/jivesoftware/openfire/spi/EncryptionArtifactFactory.java