aspose file tools*
The moose likes Web Services and the fly likes Authentication web services Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Authentication web services" Watch "Authentication web services" New topic
Author

Authentication web services

patillaldi patillaldi
Greenhorn

Joined: Jun 14, 2005
Posts: 5
I'm developing a web service who has to query other web services using a security certificates.
The remote web service calls are executed from different threads (simultaneous calls).

Which is the best way to implement security here?

When I access a single web service there is no problem. But when I try to access a second one I get the following:

AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: No trusted certificate found
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: No trusted certificate found
at com.sun.net.ssl.internal.ssl.BaseSSLSocketImpl.a(DashoA12275)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA12275)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA12275)
at com.sun.net.ssl.internal.ssl.SunJSSE_az.a(DashoA12275)
at com.sun.net.ssl.internal.ssl.SunJSSE_az.a(DashoA12275)
at com.sun.net.ssl.internal.ssl.SunJSSE_ax.a(DashoA12275)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA12275)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.j(DashoA12275)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(DashoA12275)
at org.apache.axis.components.net.JSSESocketFactory.create(JSSESocketFactory.java:224)
at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:157)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:114)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:71)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:150)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:120)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:180)
at org.apache.axis.client.Call.invokeEngine(Call.java:2564)
at org.apache.axis.client.Call.invoke(Call.java:2553)
at org.apache.axis.client.Call.invoke(Call.java:2248)
at org.apache.axis.client.Call.invoke(Call.java:2171)
at org.apache.axis.client.Call.invoke(Call.java:1691)

This is the code I use to add the security certificates:

Web Service 1:

System.setProperty('java.protocol.handler.pkgs', 'com.sun.net.ssl.internal.www.protocol');
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
System.setProperty('javax.net.ssl.keyStore', 'testkeystore.jks');
System.setProperty('javax.net.ssl.keyStorePassword','my_password');
System.setProperty('javax.net.ssl.trustStore','testtrustore.jks');
System.setProperty('javax.net.ssl.trustStorePassword','my_password');

Web Service 2:

System.setProperty('java.protocol.handler.pkgs', 'com.sun.net.ssl.internal.www.protocol');
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
System.setProperty('javax.net.ssl.keyStore', 'mio.keystore');
System.setProperty('javax.net.ssl.keyStorePassword','password');
System.setProperty('javax.net.ssl.trustStore','mio.trustore');
System.setProperty('javax.net.ssl.trustStorePassword','password');

I think the problem comes when I try to put the second System property set, they overwrite the first one and then one of the threads ends up "distrusting" the remote certificate.

Is there any way to merge both key stores and both trust stores? If so, could you add some code?

Thanks in advance.
patillaldi patillaldi
Greenhorn

Joined: Jun 14, 2005
Posts: 5
Any idea??
Originally posted by patillaldi patillaldi:
I'm developing a web service who has to query other web services using a security certificates.
The remote web service calls are executed from different threads (simultaneous calls).

Which is the best way to implement security here?

When I access a single web service there is no problem. But when I try to access a second one I get the following:

AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: No trusted certificate found
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: No trusted certificate found
at com.sun.net.ssl.internal.ssl.BaseSSLSocketImpl.a(DashoA12275)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA12275)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA12275)
at com.sun.net.ssl.internal.ssl.SunJSSE_az.a(DashoA12275)
at com.sun.net.ssl.internal.ssl.SunJSSE_az.a(DashoA12275)
at com.sun.net.ssl.internal.ssl.SunJSSE_ax.a(DashoA12275)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA12275)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.j(DashoA12275)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(DashoA12275)
at org.apache.axis.components.net.JSSESocketFactory.create(JSSESocketFactory.java:224)
at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:157)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:114)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:71)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:150)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:120)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:180)
at org.apache.axis.client.Call.invokeEngine(Call.java:2564)
at org.apache.axis.client.Call.invoke(Call.java:2553)
at org.apache.axis.client.Call.invoke(Call.java:2248)
at org.apache.axis.client.Call.invoke(Call.java:2171)
at org.apache.axis.client.Call.invoke(Call.java:1691)

This is the code I use to add the security certificates:

Web Service 1:

System.setProperty('java.protocol.handler.pkgs', 'com.sun.net.ssl.internal.www.protocol');
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
System.setProperty('javax.net.ssl.keyStore', 'testkeystore.jks');
System.setProperty('javax.net.ssl.keyStorePassword','my_password');
System.setProperty('javax.net.ssl.trustStore','testtrustore.jks');
System.setProperty('javax.net.ssl.trustStorePassword','my_password');

Web Service 2:

System.setProperty('java.protocol.handler.pkgs', 'com.sun.net.ssl.internal.www.protocol');
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
System.setProperty('javax.net.ssl.keyStore', 'mio.keystore');
System.setProperty('javax.net.ssl.keyStorePassword','password');
System.setProperty('javax.net.ssl.trustStore','mio.trustore');
System.setProperty('javax.net.ssl.trustStorePassword','password');

I think the problem comes when I try to put the second System property set, they overwrite the first one and then one of the threads ends up "distrusting" the remote certificate.

Is there any way to merge both key stores and both trust stores? If so, could you add some code?

Thanks in advance.
Manjunatha N.S.
Greenhorn

Joined: Dec 30, 2003
Posts: 16
Hi,

what I understood from your question is like You have Developed WebService-A, which in turn Access WebService-B. When user Access the Webservice-A it works fine and but when accessing webserivce-B, it return SOAP Fault exception saying Certificate not found.

If above my understanding is correct, the problem is with accessing WebService-B from the Webservice-A with SSL Connection. So for that you should crate TrustStore in your server(server where webservice-A is deployed) and import the ServerCertificate of the webservice-B into that TrustStore. Then it should start working..

regards
Manju
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Authentication web services