I have a trouble with ssl , and need your help ,thanks a lot!

04-06-10 yyand23
Hello everyone!

I have a trouble with ssl , and need your help ,thanks a lot!

I use Tomcat4.0 + ssl + saop to translate data , get a Exception as below:

Error opening socket: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: No trusted certificate found

Here is my simple code,I send data two time ,one is to 172.16.4.201,and other is to 172.16.4.62 . and when send to 201 ,use certification is "c:\\test\\myKeystore". When send to 62 ,use certification is c:\\test\\abc :

/** Here is the First send data */

Send send1 = Send.getInstance();

Info info1 = new Info();

info.setTransContent(“aaaaaaaaaaaaaa”);

info1.setCertificateKeyStore("c:\\test\\myKeystore");

info1.setUseHttps(true);

info1.setTargetSystem(

"https://172.16.4.201:8443/soap/servlet/rpcrouter");

try {

send1.sendString(info1);

} catch (Exception e) {

e.printStackTrace();

}

/** Here is the Second send data*/

Send send = Send.getInstance();

Info info = new Info();

info.setTransContent(“bbbbbbbbbbbbbbb”);

info.setCertificateKeyStore("c:\\test\\abc");

info.setUseHttps(true);

info.setTargetSystem(

"https://172.16.4.62:8443/soap/servlet/rpcrouter");

try {

send.sendString(info);

} catch (Exception e) {

e.printStackTrace();

}

these code was write in my java appalication,when I run this ,will get error above ,say that No trusted certificate found.but ,if I only run the first send ,or I only run the second send ,that will be ok ,will no error .why ??

I think may be first use certification ,then system catched the content ,so when I send the second time ,that need use other certification,but system still use first certification.

I use below code to remove catched :

System.setProperty("networkaddress.cache.ttl ","0");

But has no effect!

By the way , I use

System.setProperty("javax.net.debug","all");

And in the debug info ,I saw that system read Certificate chain for two times ,and ervery time it is not the same ,it is said that system has read two deferent certification ,but why he still say No trusted certificate found??

猜你喜欢