FileDocCategorySizeDatePackage
X509TrustManagerExtensions.javaAPI DocAndroid 5.1 API3216Thu Mar 12 22:22:10 GMT 2015android.net.http

X509TrustManagerExtensions

public class X509TrustManagerExtensions extends Object
X509TrustManager wrapper exposing Android-added features.

The checkServerTrusted method allows callers to perform additional verification of certificate chains after they have been successfully verified by the platform.

Fields Summary
com.android.org.conscrypt.TrustManagerImpl
mDelegate
Constructors Summary
public X509TrustManagerExtensions(X509TrustManager tm)
Constructs a new X509TrustManagerExtensions wrapper.

param
tm A {@link X509TrustManager} as returned by TrustManagerFactory.getInstance();
throws
IllegalArgumentException If tm is an unsupported TrustManager type.

        if (tm instanceof TrustManagerImpl) {
            mDelegate = (TrustManagerImpl) tm;
        } else {
            throw new IllegalArgumentException("tm is an instance of " + tm.getClass().getName() +
                    " which is not a supported type of X509TrustManager");
        }
    
Methods Summary
public java.util.ListcheckServerTrusted(java.security.cert.X509Certificate[] chain, java.lang.String authType, java.lang.String host)
Verifies the given certificate chain.

See {@link X509TrustManager#checkServerTrusted(X509Certificate[], String)} for a description of the chain and authType parameters. The final parameter, host, should be the hostname of the server.

throws
CertificateException if the chain does not verify correctly.
return
the properly ordered chain used for verification as a list of X509Certificates.

        return mDelegate.checkServerTrusted(chain, authType, host);
    
public booleanisUserAddedCertificate(java.security.cert.X509Certificate cert)
Checks whether a CA certificate is added by an user.

Since {@link X509TrustManager#checkServerTrusted} allows its parameter {@code chain} to chain up to user-added CA certificates, this method can be used to perform additional policies for user-added CA certificates.

return
{@code true} to indicate that the certificate was added by the user, {@code false} otherwise.

        return mDelegate.isUserAddedCertificate(cert);