Problem executing web service client using HTTPS

Hi !

I am programing a web service client that uses HTTPS.

I use the SUN One Appserver7.

I work with the example SUNWappserver7/samples/webservices/jaxrpc/simple

I configure the port 555 for using HTTPS.

The code that I use is:

Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider() );

System.setProperty("javax.net.ssl.keyStore"

,"/usr/j2se/jre/lib/security/cacerts");

System.setProperty("javax.net.ssl.keyStoreType"

,"pkcs12");

/*,"KeyStore.getDefaultType()"); */

System.setProperty("javax.net.ssl.keyStorePassword"

,"changeit");

System.setProperty("javax.net.ssl.trustStore"

, "/usr/j2se/jre/lib/security/cacerts");

System.setProperty("javax.net.ssl.trustStoreType"

,"KeyStore.getDefaultType()");

System.setProperty("javax.net.ssl.trustStorePassword"

, "changeit");

System.setProperty("java.protocol.handler.pkgs"

,"com.sun.net.ssl.internal.www.protocol");

Stub stub = createProxy();

HelloIF hello = (HelloIF)stub;

System.out.println(hello.sayHello("Duke!"));

With this configuration the error displayed is:

java.rmi.RemoteException: HTTP transport error: java.net.SocketException: Default SSL context init failed: DerInputStream.getLength(): lengthTag=109, too big.; nested exception is:

HTTP transport error: java.net.SocketException: Default SSL context init failed: DerInputStream.getLength(): lengthTag=109, too big.

at samples.webservices.jaxrpc.simple.HelloIF_Stub.sayHello(HelloIF_Stub.java:77)

at samples.webservices.jaxrpc.simple.HelloClient.main(Unknown Source)

Caused by: HTTP transport error: java.net.SocketException: Default SSL context init failed: DerInputStream.getLength(): lengthTag=109, too big.

at com.sun.xml.rpc.client.http.HttpClientTransport.invoke(HttpClientTransport.java:140)

at com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:92)at samples.webservices.jaxrpc.simple.HelloIF_Stub.sayHello(HelloIF_Stub.java:60)

... 1 more

Does anybody have an idea what is happening here ?

In advance, thanks.

Ricardo

[2187 byte] By [rdlarosa2@yahoo.coma] at [2007-9-30 23:39:39]
# 1
Hi,I get the same exception. I am useing Axis over Tomcat.have you found a solution for that Exception?any help would be highly appreciated.L.
lepinapaa at 2007-7-7 14:53:45 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2

Your keystore file is most likely corrupted. Try looking at its contents with the keytool again.

I had a very similar error message after a keystore file was checked into CVS without the binary flag set (cvs admin -kb), then checked out and deployed within an EAR file.

It took the better part of a day to determine the problem because the web application was making an SSL connection to a server that didn't require the client SSL certificate, although the keystore was being read anyway due to the System property being set.

Dave

ddkilzera at 2007-7-7 14:53:45 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3

Hi

I am having the same problem almost where i wrote a client to comsume a JWS server in https. Where the server is setup to require a certificate to connect to.

My code:

public static void main(String[] args) {

try {

DataBaseSyncServerImpl port = new DataBaseSyncServerImplService().getDataBaseSyncServerImplPort();

int number1 = 20;

int number2 = 10;

System.out.printf("Invoking divide method(%d, %d)\n", number1, number2);

double result = port.divide(number1, number2);

System.out.printf("The result of dividing %d and %d is %f.\n\n", number1, number2, result);

}

when run this code throw

run:

[java] Invoking divide method(20, 10)

[java] Exception in thread "main" javax.xml.ws.WebServiceException: HTTP transport error: javax.net.ssl.SSLHandshak

eException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCert

PathBuilderException: unable to find valid certification path to requested target

Does any one know how can I solve this problem or how can I make the client be able to use self signed certificates. Any help is greatly apprecited. Thanks

martineza at 2007-7-7 14:53:45 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 4
Are you sure you're using a PKCS12 KeyStore, and not a JKS? That would produce the error you are seeing.
rlmcgra at 2007-7-7 14:53:45 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...