public static Set<TrustAnchor> toTrustAnchors( X509Certificate... certificates )
    {
        final Set<TrustAnchor> result = new HashSet<>();
        for ( X509Certificate certificate : certificates )
        {
            if ( certificate == null)
            {
                continue;
            }
            result.add( new TrustAnchor( certificate, null ) );
        }

        return result;
    }
Transforms an array of certificates into TrustAnchor instances.

This method does not set the nameConstraints parameter of the generated TrustAnchors.

The return value of this method is a Set, which means that duplicate certificates in the input are implicitly
being removed from the result.

@param certificates An array of certificates (possibly empty, possibly null).
@return A Set of valid certificates (possibly empty, but never null).
xmppserver/src/main/java/org/jivesoftware/openfire/keystore/CertificateUtils.java