<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">
<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>
                                <td>
                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">Community</a></h1>
                                                                </td>
                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px; -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
JBoss WS and setting own trustmanager
</h3>
<span style="margin-bottom: 10px;">
created by <a href="http://community.jboss.org/people/zlytomek">Tomasz Dźwigaj</a> in <i>JBoss Web Services</i> - <a href="http://community.jboss.org/message/546832#546832">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p>Hi.</p><p>My main goal is to have a trustmanager filled with certificates retrieved from a database for a secure WebService client connections with JBoss Ws.</p><p>I've created my own implementation of trustmanager which implements javax.net.ssl.X509TrustManager, and it's basically getting certs from a database and loads them into keystore. I'm setting it for my HTTPSConnections like this:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>...</p><p>TrustManager[] myTMs = new TrustManager [] {<br/>                myTrustManager };</p><p>final SSLContext sslContext = SSLContext.getInstance( "TLS" );</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>sslContext.init( null, myTMs, null );</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>HttpsURLConnection.setDefaultSSLSocketFactory( sslContext.getSocketFactory() );</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Althought it works fine (the webservice is call is made properly) at every connection it messes with my head with:</p><p><br/>java.io.IOException: Error initializing socket factory SSL context: Can not find truststore url.<br/>        at org.jboss.remoting.security.SSLSocketBuilder.initializeSocketFactorySSLContext(SSLSocketBuilder.java:1340)<br/>        at org.jboss.remoting.security.SSLSocketBuilder.createCustomSocketFactory(SSLSocketBuilder.java:451)<br/>        at org.jboss.remoting.security.SSLSocketBuilder.createSSLSocketFactory(SSLSocketBuilder.java:431)<br/>        at org.jboss.remoting.security.SSLSocketBuilder.createSSLSocketFactory(SSLSocketBuilder.java:381)<br/>        at org.jboss.remoting.transport.http.ssl.HTTPSClientInvoker.createSocketFactory(HTTPSClientInvoker.java:140)<br/>        at org.jboss.remoting.RemoteClientInvoker.<init>(RemoteClientInvoker.java:46)<br/>        at org.jboss.remoting.transport.http.HTTPClientInvoker.<init>(HTTPClientInvoker.java:105)<br/>        at org.jboss.remoting.transport.http.ssl.HTTPSClientInvoker.<init>(HTTPSClientInvoker.java:63)<br/>        at org.jboss.remoting.transport.https.TransportClientFactory.createClientInvoker(TransportClientFactory.java:39)<br/>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br/>        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)<br/>        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)<br/>        at java.lang.reflect.Method.invoke(Method.java:597)<br/>        at org.jboss.remoting.InvokerRegistry.loadClientInvoker(InvokerRegistry.java:419)<br/>        at org.jboss.remoting.InvokerRegistry.createClientInvoker(InvokerRegistry.java:320)<br/>        at org.jboss.remoting.Client.connect(Client.java:459)<br/>        at org.jboss.ws.core.client.RemotingConnectionImpl.createRemotingClient(RemotingConnectionImpl.java:247)<br/>        at org.jboss.ws.core.client.RemotingConnectionImpl.invoke(RemotingConnectionImpl.java:165)<br/>        at org.jboss.ws.core.client.SOAPRemotingConnection.invoke(SOAPRemotingConnection.java:77)<br/>        at org.jboss.ws.core.CommonClient.invoke(CommonClient.java:337)<br/>        at org.jboss.ws.core.jaxws.client.ClientImpl.invoke(ClientImpl.java:243)<br/>        at org.jboss.ws.core.jaxws.client.ClientProxy.invoke(ClientProxy.java:164)<br/>        at org.jboss.ws.core.jaxws.client.ClientProxy.invoke(ClientProxy.java:150)</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>So i've tried to set a java system property javax.net.ssl.trustStore to an empty keystore and althought it worked fine on a windows server (the annoying exception was gone) on a linux server, after setting this property this empty keystore was used as a truststore which only gave me another nightmane - what if in other part of code of large application i'm dealing with - somebody is setting this property for his reasons?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Maybe anyone found some solution for this problem?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>I'm using I'm using Jboss 4.2.2</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Regards</p><p>zlytomek</p></div>
<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
<p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/546832#546832">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JBoss Web Services at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2044">Community</a></p>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>