java - How to build the EndPoint correctly using jax-ws? -
i using bootstrap method build endpoints dynamically making wsdl available locally. both http , https, pretty sure going somewhere wrong while building them https.
map<string, object> context = ((bindingprovider)control).getrequestcontext(); url address = minstance.getconnectionendpoint(); if (address != null && settings.getsettings().isusinghttpconnection()) { context.put(bindingprovider.endpoint_address_property,address.tostring()); system.out.println(address); } else{ //for https httpsurlconnection.setdefaulthostnameverifier(new hostnameverifier() { public boolean verify(string hostname, sslsession session) { if (hostname.equals("myhostname")) return true; return false; } }); address = minstance.getsecureconnectionendpoint(); context.put(bindingprovider.endpoint_address_property,address.tostring()); }
where getconnectionendpoint , getsecureconnectionendpoint like:
public url getconnectionendpoint() { url url = null; try { int port = 50013; url = new url("http", mhost.gethostaddress(), port, ""); } catch (malformedurlexception e) { e.printstacktrace(); } return url; } public url getsecureconnectionendpoint() { url url = null; try { int port = 50014; url = new url("https", mhost.gethostaddress(), port, ""); } catch (malformedurlexception e) { e.printstacktrace(); } return url; }
this works fine when use http. https end getting error says:
com.sun.xml.internal.ws.client.clienttransportexception: http transport error: javax.net.ssl.sslhandshakeexception: java.security.cert.certificateexception: no subject alternative names present
obviously googling error found answers might due improper importing of server , client ssl certificates in java truststore.
but pretty confident issue not that.
the child errors of parent error mentioned above this:
at sun.security.ssl.sslsocketimpl.starthandshake(unknown source) @ sun.security.ssl.sslsocketimpl.starthandshake(unknown source) @ sun.net.www.protocol.https.httpsurlconnectionimpl.getoutputstream(unknown source)
i grateful if can me solve issue! cheers in advance.
the problem value returned mhost.gethostaddress()
different hostname common name on certificate offered server. example, if localhost
the value of mhost.gethostaddress()
yet ssl cert issued 127.0.0.1
(or vice versa) may issue.
this post identifies code workaround in case regenerating , reinstalling certificate different cn not viable or desirable. involves using hostnameverifier mechanism of httpsurlconnection.
Comments
Post a Comment