Java.security.cert.CertificateException:No Subject Alternative Names present

Source: Internet
Author: User
Tags ssl certificate ssl connection wsdl

Background: In the development of a project, to invoke a WebService service, previously set up an HTTP protocol, the project in the JDK with the Wsimport tool generated by the client code;

Later, requirements change requirements compatible with HTTPS protocol WebService, began to think that simply need to change the service address of the connection to HTTPS, but no, always error

Javax.net.ssl.SSLHandshakeException:java.security.cert.CertificateException:No Subject Alternative names Present at Com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.tryWithMex (Unknown Source) at com.sun.xml.internal . Ws.wsdl.parser.RuntimeWSDLParser.parse (Unknown Source) at Com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse (Unknown Source) at Com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse (Unknown Source) at Com.sun.xml.internal.ws.client.WSServiceDelegate.parseWSDL (Unknown Source) at Com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(Unknown Source) at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(Unknown Source) at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(Unknown Source) at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(Unknown source) at Com.sun.xml.internal.ws.spi.ProviderImpl.createServiceDelegate (Unknown source) at Javax.xml. Ws. Service.<init>(Unknown Source) at Com.vrv.paw.client.area.VRVRange.<init> (vrvrange.java:48) at Com.vrv.paw.client.area.mainTest.main (Maintest.java:02H

Then this is the Baidu search information, find the following explanations

http://www.nakov.com/blog/2009/07/16/disable-certificate-validation-in-java-ssl-connections/

In the development design when we open an SSL connection in Java (for example: Java.net.URL.openConnection ("https://...")),
The SSL protocol implemented by Jsse performs some validation to ensure that the host for this request is not fake.
This includes using the PKIX algorithm to verify the server's Certificate of honor and checking that the host name is consistent with the subject in the certificate.
If the SSL certificate is not trusted or does not match the target host, HTTPS and SSL encrypted connections cannot be established and thrown sslhandshakeexception or IOException


The JSSE implementation of the SSL protocol performs few validations to ensure the requested host are not fake.


An HTTPS and other SSL encrypted connection cannot is established and all attempts would result in sslhandshakeexception or IOException.

It's all about adding the SLL data certificate to the Ketstore.

The certificate is also generated according to the method that http://www.cnblogs.com/liaojie970/p/4919485.html always mentions, and in the code

System.setproperty ("Javax.net.ssl.trustStore", "E:\\vrvcacerts"); System.setproperty ("Javax.net.ssl.trustStorePassword", "Changeit"); 
 PackageCom.vrv.paw.client.area; Public classMaintest { Public Static voidMain (string[] args) {System.setproperty ("Javax.net.ssl.trustStore", "E:\\vrvcacerts"); System.setproperty ("Javax.net.ssl.trustStorePassword", "Changeit"); Gson Gson=NewGson (); //Synchronizing DataVrvrange Vrvrange =NewVrvrange (); Vrvrangesoap Vrvrangesoap=Vrvrange.getvrvrangesoap (); String cString= Vrvrangesoap.login ("admin", "123456");        System.out.println (cString);     }}

The problem is still there, and there is no way to try to create a new WSDL file in the project, right-click the WSDL file in Eclipse, and the web Service-->generate client to generate the clients, see here

And then again

 PackageOrg.tempuri;Importjava.rmi.RemoteException;Importjavax.xml.rpc.ServiceException; Public classTestClient { Public Static voidMain (string[] args) {Try{System.setproperty ("Javax.net.ssl.trustStore", "E:\\jssecacerts"); System.setproperty ("Javax.net.ssl.trustStorePassword", "Changeit"); Gson Gson=NewGson (); Vrvrange Vrvrange=NewVrvrangelocator (); Vrvrangesoap Vrvrangesoap=Vrvrange.getvrvrangesoap (); String Login= Vrvrangesoap.login ("admin", "123456");           SYSTEM.OUT.PRINTLN (login);         } Catch(serviceexception e) {e.printstacktrace (); } Catch(RemoteException e) {e.printstacktrace (); }    }}

The result became ....

Specifically why Wsimport generated client code does not work, I do not know, if there is any big God know, please advise.

Java.security.cert.CertificateException:No Subject Alternative Names present

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.