Class TrustAllTrustManager

  extended by
All Implemented Interfaces:
TrustManager, X509TrustManager

public class TrustAllTrustManager
extends Object
implements X509TrustManager

Normally when we connect over HTTPS, if the server sends us a certificate that is not well known, we have to specify a keystore using system properties:

System.setProperty("","path to keystore" ); System.setProperty("","apache");

Using this X509TrustManager we can allow the client to disregard the certificate and trust the server. One of the reason this may be done is because clients are sometimes deployed on systems where the developers haveno access to the file system and therefore cannot configure the keystores.

This TrustManager can be used in the client stub as follows:

 SSLContext sslCtx = SSLContext.getInstance("http");
 sslCtx.init(null, new TrustManager[] {new TrustAllTrustManager()}, null);
          new Protocol("https",(ProtocolSocketFactory)new SSLProtocolSocketFactory(sslCtx),443));

See Also:

Constructor Summary
Method Summary
 void checkClientTrusted(X509Certificate[] certs, String authType)
 void checkServerTrusted(X509Certificate[] certs, String authType)
 X509Certificate[] getAcceptedIssuers()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public TrustAllTrustManager()
Method Detail


public X509Certificate[] getAcceptedIssuers()
Specified by:
getAcceptedIssuers in interface X509TrustManager


public void checkClientTrusted(X509Certificate[] certs,
                               String authType)
Specified by:
checkClientTrusted in interface X509TrustManager


public void checkServerTrusted(X509Certificate[] certs,
                               String authType)
Specified by:
checkServerTrusted in interface X509TrustManager

Copyright © 2004-2011 The Apache Software Foundation. All Rights Reserved.