java 8 - SNIMatcher not returning correct certificate -
i have server , i've added snimatcher based on example
http://docs.oracle.com/javase/8/docs/technotes/guides/security/jsse/jsserefguide.html#sniexamples
sslserversocket sslserversocket = ...; snimatcher matcher = snihostname.createsnimatcher("www\\.example\\.(com|org)"); collection<snimatcher> matchers = new arraylist<>(1); matchers.add(matcher); sslparameters params = sslserversocket.getsslparameters(); params.setsnimatchers(matchers); sslserversocket.setsslparameters(params);
i've added example.com , example.org in hosts file 127.0.0.1
when go example.com , example.org both same localhost certificate (i've created separate certificate example.org)
my question what's correct way attach snimatcher
do need create separate matcher each virtual host has own certificate? (i did got illegalargumentexception because both hosts had same type 0 (standardconstants.sni_host_name)
so changed way attaching , did way example (com|org) it's returning same certificate both. wondering what's correct way?
thank you
i believe has x509 stuff (distinguished name) in certs of keys in keystore used sslcontext issued sslserversocketfactory.
choosing key , presenting x509 cert (given "merely accepted" sni hostname) has dn in x509 because that's mapping knowledge available. host mapping not done keystore alias! mapping information keystore has in cert, hostname certificate authority has signed.
afaik, sni server-side mechanism doesn't key selection, restricts hostnames allowed entire keystore/keymanager hooked up.
ps: if wanted switch keystores, have build sslcontext x509keymanager of own can provide material of key stores. wrap array of key managers out of keymanagerfactory... , support ends here me because gets ugly fast recall!
Comments
Post a Comment