public synchronized TrustManager[] getTrustManagers() throws KeyStoreException, NoSuchAlgorithmException
    {
        // Implementation note: Various consumers of this method (in this same class) expect exactly one result. If this implementation is ever
        //                      modified to allow for more than one TrustManager to be returned, be sure to modify those consumers accordingly!

        final Class<TrustManager> trustManagerClass = (Class<TrustManager>) TRUST_MANAGER_CLASS.getValue();
        Log.debug( "Configured TrustManager class: {}", trustManagerClass.getCanonicalName() );

        try
        {
            Log.debug( "Attempting to instantiate '{}' using the four-argument constructor that is proprietary to Openfire.", trustManagerClass );
            final Constructor<TrustManager> constructor = trustManagerClass.getConstructor( KeyStore.class, Boolean.TYPE, Boolean.TYPE, Boolean.TYPE );
            final TrustManager trustManager = constructor.newInstance( configuration.getTrustStore().getStore(), configuration.isAcceptSelfSignedCertificates(), configuration.isVerifyCertificateValidity(), configuration.isVerifyCertificateRevocation() );
            Log.debug( "Successfully instantiated '{}'.", trustManagerClass );
            return new TrustManager[] { trustManager };
        }
        catch ( Exception e )
        {
            Log.debug( "Unable to instantiate '{}' using the four-argument constructor that is proprietary to Openfire. Trying to use a no-arg constructor instead...", trustManagerClass );
            try
            {
                final TrustManager trustManager = trustManagerClass.newInstance();
                Log.debug( "Successfully instantiated '{}'.", trustManagerClass );

                return new TrustManager[] { trustManager };
            }
            catch ( InstantiationException | IllegalAccessException ex )
            {
                Log.warn( "Unable to instantiate an instance of the configured Trust Manager implementation '{}'. Using {} instead.", trustManagerClass, OpenfireX509TrustManager.class, ex );
                return new TrustManager[] { new OpenfireX509TrustManager( configuration.getTrustStore().getStore(), configuration.isAcceptSelfSignedCertificates(), configuration.isVerifyCertificateValidity(), configuration.isVerifyCertificateRevocation() )};
            }
        }
    }
Generates TrustManager instances suitable for connections that are created based on a particular configuration.

@return TrustManagers applicable to a connection that is established using the provided configuration.
@throws KeyStoreException if there was a problem accessing the keystore
@throws NoSuchAlgorithmException if the algorithm is not supported
xmppserver/src/main/java/org/jivesoftware/openfire/spi/EncryptionArtifactFactory.java