I have coded a custom TrustManger and HostnameVerifier for SSL (actually TLS) 
connections from my servlet code to another server.

The code calls the correct methods to setup the Default TrustManager and 
HostNameVerifier for an HttpsUrlConnection.

I then use the URL.openConnection() method to instansiate the connection.

Running standalone, this code works perfectly, however running under Tomcat on the 
same machine the HttpConnection does not use the custom TustManager that I coded.

Any suggestions?


Code to set up default Trust Manager, etc.:

private static void initSSL()
{
  try
  {
    TrustManager[] myTM = new TrustManager [] { new ProxyTrustManager() };
    SSLContext ctx = SSLContext.getInstance("TLS");
    ctx.init(null, myTM, null);
    SSLSocketFactory sslFactory = ctx.getSocketFactory();
    HttpsURLConnection.setDefaultSSLSocketFactory(sslFactory);
    HttpsURLConnection.setDefaultHostnameVerifier(new ProxyHostNameVerifier());
  }
  catch (Exception ex)
  {
    ex.printStackTrace();
  }
}


-- Nathan Christiansen
   Tahitian Noni International
   http://www.tahitiannoni.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to