• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Authentication web services

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
It sure was nice of your sister to lend us her car. Let's show our appreciation by sharing this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic