java - JAX-WS ignore TLS certificate -


i have generated java classes wsimport command. @ moment, i'm trying ignore tls certificate call soap service. needed add bindingprovider because have custom endpoint/authentication.

this code:

bzorderasynchout service = new bzorderasynchout(); bzorderasynchout port = service.gethttpsport();  // use bindingprovider's context set endpoint bindingprovider bp = (bindingprovider)port;     bp.getrequestcontext().put(bindingprovider.endpoint_address_property, endpoint); bp.getrequestcontext().put(bindingprovider.username_property, usuario); bp.getrequestcontext().put(bindingprovider.password_property, senha); bp.getrequestcontext().put("com.sun.xml.ws.transport.https.client.sslsocketfactory", gettrustingsslsocketfactory()); bp.getrequestcontext().put("com.sun.xml.ws.transport.https.client.hostname.verifier", new naivehostnameverifier()); port.bzorderasynchout(object);  public static sslsocketfactory gettrustingsslsocketfactory() {         return sslsocketfactoryholder.instance;     }      private static sslsocketfactory createsslsocketfactory() {         trustmanager[] trustmanagers = new trustmanager[]{             new naivetrustmanager()         };         sslcontext sslcontext;         try {             sslcontext = sslcontext.getinstance("ssl");             sslcontext.init(new keymanager[0], trustmanagers, new securerandom());             httpsurlconnection.setdefaultsslsocketfactory(sslcontext.getsocketfactory());              return sslcontext.getsocketfactory();         } catch (generalsecurityexception e) {             return null;         }     }      private static interface sslsocketfactoryholder {          public static final sslsocketfactory instance = createsslsocketfactory();     }      private static class naivehostnameverifier implements hostnameverifier {          @override         public boolean verify(string hostname, sslsession session) {             return true;         }     }      private static class naivetrustmanager implements x509trustmanager {          @override         public void checkclienttrusted(java.security.cert.x509certificate[] certs, string authtype) throws java.security.cert.certificateexception {         }          @override         public void checkservertrusted(java.security.cert.x509certificate[] certs, string authtype) throws java.security.cert.certificateexception {         }          @override         public java.security.cert.x509certificate[] getacceptedissuers() {             return new java.security.cert.x509certificate[0];         }     } 

the error when call service is:

caused by: java.io.ioexception: https url hostname not match  common name (cn) on server certificate in client's truststore.   make sure server certificate correct, or disable check (not recommended production) set cxf client tls configuration  property "disablecncheck" true. 

i'm trying solve problem getrequestcontext params.


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -