java - Extended server_name (SNI Extension) not sent with jdk1.8.0 but send with jdk1.7.0 -
i have implemented jax-ws client using apachecxf (v3.0.4) , works problem comes when want use secure connection (ssl/tls) java 8 (jdk1.8.0_25).
i see following exception in log (-djavax.net.debug=all):
main, handling exception: java.net.socketexception: connection reset main, send tlsv1.2 alert: fatal, description = unexpected_message main, write: tlsv1.2 alert, length = 2 main, exception sending alert: java.net.socketexception: connection reset peer: socket write error
after depeer analysis have observed problem caused because java 8 server_name (sni) not sent java 7 sent , web service invocation works successfully.
java 8 log (-djavax.net.debug=all): missing "extension server_name"
[...] compression methods: { 0 } extension elliptic_curves, curve names: {secp256r1, sect163k1, sect163r2, secp192r1, secp224r1, sect233k1, sect233r1, sect283k1, sect283r1, secp384r1, sect409k1, sect409r1, secp521r1, sect571k1, sect571r1, secp160k1, secp160r1, secp160r2, sect163r1, secp192k1, sect193r1, sect193r2, secp224k1, sect239k1, secp256k1} extension ec_point_formats, formats: [uncompressed] extension signature_algorithms, signature_algorithms: sha512withecdsa, sha512withrsa, sha384withecdsa, sha384withrsa, sha256withecdsa, sha256withrsa, sha224withecdsa, sha224withrsa, sha1withecdsa, sha1withrsa, sha1withdsa, md5withrsa *** [...]
java 7 log (-djavax.net.debug=all) (works): "extension server_name" set
[...] compression methods: { 0 } extension elliptic_curves, curve names: {secp256r1, sect163k1, sect163r2, secp192r1, secp224r1, sect233k1, sect233r1, sect283k1, sect283r1, secp384r1, sect409k1, sect409r1, secp521r1, sect571k1, sect571r1, secp160k1, secp160r1, secp160r2, sect163r1, secp192k1, sect193r1, sect193r2, secp224k1, sect239k1, secp256k1} extension ec_point_formats, formats: [uncompressed] extension signature_algorithms, signature_algorithms: sha512withecdsa, sha512withrsa, sha384withecdsa, sha384withrsa, sha256withecdsa, sha256withrsa, sha224withecdsa, sha224withrsa, sha1withecdsa, sha1withrsa, sha1withdsa, md5withrsa extension server_name, server_name: [host_name: testeo.hostname.es] *** [...]
it observed java 7 extension server_name, server_name: [host_name: testeo.hostname.es] set , web service invocation works successfully.
why didn't java 8 set server_name java 7 did? java configuration issue?
as mentioned, cause related jdk bug using sethostnameverifier() breaks sni (extension server_name). https://bugs.openjdk.java.net/browse/jdk-8144566
our workaround: after testing found setting connection's sslsocketfactory default seems fix issue.
this not work: httpsurlconnection.setsslsocketfactory((sslsocketfactory) sslsocketfactory.getdefault());
this work: httpsurlconnection.setsslsocketfactory(new sslsocketfactoryfacade());
so, fix jax-ws client, this: bindingprovider.getrequestcontext().put("com.sun.xml.internal.ws.transport.https.client.sslsocketfactory", new sslsocketfactoryfacade());
our sslsocketfactory facade: (note doesn't anything)
public class sslsocketfactoryfacade extends sslsocketfactory { sslsocketfactory sslsf; public sslsocketfactoryfacade() { sslsf = (sslsocketfactory) sslsocketfactory.getdefault();; } @override public string[] getdefaultciphersuites() { return sslsf.getdefaultciphersuites(); } @override public string[] getsupportedciphersuites() { return sslsf.getsupportedciphersuites(); } @override public socket createsocket(socket socket, string s, int i, boolean b) throws ioexception { return sslsf.createsocket(socket, s, i, b); } @override public socket createsocket(string s, int i) throws ioexception, unknownhostexception { return sslsf.createsocket(s, i); } @override public socket createsocket(string s, int i, inetaddress inetaddress, int i1) throws ioexception, unknownhostexception { return sslsf.createsocket(s, i, inetaddress, i1); } @override public socket createsocket(inetaddress inetaddress, int i) throws ioexception { return createsocket(inetaddress, i); } @override public socket createsocket(inetaddress inetaddress, int i, inetaddress inetaddress1, int i1) throws ioexception { return createsocket(inetaddress, i, inetaddress1, i1); } }
Comments
Post a Comment