Can't use SNI filter on HTTPS server with Grizzly 2.3.19 -


i'm trying client sni app, integration test i'm using grizzly server test sni being passed. i'm using filter per docs. filter never called.

the documentation doesn't show complete example. mechanism i've found add filters seems ignored. old method used in 2.2 not public anymore.

the following code:

private tcpniotransport createmockservertransport() {     final sslengineconfigurator sslserverengineconfig = new sslengineconfigurator(createsslcontextconfigurator().createsslcontext(), false, false, false);     return tcpniotransportbuilder.newinstance().setprocessor(getfilters()).build(); }  private filterchain getfilters() {     snifilter snifilter = getsnifilter();      final filterchain chain = filterchainbuilder.stateless()             .add(new transportfilter())             .add(snifilter)             .add(new stringfilter())             .add(new basefilter() {                 @override                 public nextaction handleread(final filterchaincontext ctx)                         throws ioexception {                     return ctx.getinvokeaction();                 }             })             .build();      return chain; }  private snifilter getsnifilter() {     final attribute<string> snihostattr = grizzly.default_attribute_builder.createattribute("sni-host-attr");      snifilter snifilter = new snifilter();     snifilter.setserversslconfigresolver(new sniserverconfigresolver() {         @override         public sniconfig resolve(connection connection, string hostname) {             snihostattr.set(connection, hostname);             if (stringutils.isempty(hostname)) {                 throw new illegalargumentexception("sni has not been sent");             }             return sniconfig.newserverconfig(sslserverengineconfig);         }     });     return snifilter; }  private sslcontextconfigurator createsslcontextconfigurator() {     sslcontextconfigurator sslcontextconfigurator = new sslcontextconfigurator();     classloader cl = httprequestsnitestcase.class.getclassloader();      url cacertsurl = cl.getresource("truststore");     if (cacertsurl != null) {         sslcontextconfigurator.settruststorefile(cacertsurl.getfile());         sslcontextconfigurator.settruststorepass("mypassword");     }      url keystoreurl = cl.getresource("serverkeystore");     if (cacertsurl != null) {         sslcontextconfigurator.setkeystorefile(keystoreurl.getfile());         sslcontextconfigurator.setkeystorepass("mypassword");         sslcontextconfigurator.setkeypass("mypassword");     }      return sslcontextconfigurator; }   public class server {     private httpserver webserver;      protected void startserver() throws ioexception {         sslengineconfigurator sslserverengineconfig = new sslengineconfigurator(createsslcontextconfigurator().createsslcontext(), false, false, false);          networklistener networklistener = new networklistener("sample-listener", "localhost", httpsport.getnumber());         networklistener.settransport(createmockservertransport());           networklistener.setsslengineconfig(sslserverengineconfig);          webserver = httpserver.createsimpleserver();         webserver.addlistener(networklistener);         networklistener.setsecure(true);          networklistener.gettransport().setprocessor(getfilters());          filterchain chain = networklistener.getfilterchain();         webserver.start();     }      protected void stopserver() {         webserver.shutdownnow();     } } 

in order update httpserver filter chain have use addon:

protected void startserver() throws ioexception {     networklistener networklistener = new networklistener("sample-listener", "localhost", 8081);     sslserverengineconfig = new sslengineconfigurator(createsslcontextconfigurator().createsslcontext(), false, false, false);     networklistener.setsslengineconfig(sslserverengineconfig);     networklistener.setsecure(true);     networklistener.registeraddon(new sniaddon());      webserver = httpserver.createsimpleserver();     webserver.addlistener(networklistener);      webserver.start(); }  private class sniaddon implements addon {      public void setup(networklistener networklistener,             filterchainbuilder builder) {         // replace sslfilter (if any) snifilter         final int idx = builder.indexoftype(sslbasefilter.class);         if (idx != -1) {             builder.set(idx, getsnifilter());         }     } } 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -