Hi,

I have a use case where I need to connect to a remote server that requires
SNI. I am using mina version 2.0.0-M6.

In org.apache.mina.filter.ssl.SslHandler, I see this code:

        InetSocketAddress peer = (InetSocketAddress) session
                .getAttribute(SslFilter.PEER_ADDRESS);

        // Create the SSL engine here
        if (peer == null) {
            sslEngine = sslContext.createSSLEngine();
        } else {
            sslEngine = sslContext.createSSLEngine(peer.getHostName(),
peer.getPort());
        }

However, the problem is, I don't know how to add SslFilter.PEER_ADDRESS
attribute so that it will be available when SslHandler creates sslEngine.

This is how I connect to the remote server:
        ExecutorService connectorPool = Executors.newFixedThreadPool(20);
        NioProcessor connectorProcessor = new NioProcessor(connectorPool);
        NioSocketConnector connector = new
NioSocketConnector(connectorPool, connectorProcessor);
        connector.setHandler(new DummyIoHandler());

        connector.getFilterChain().addLast("httpCodec",
                new ProtocolCodecFilter(new HttpCodecFactory()));

        SSLConnectorFilter sslConnectorFilter = new SSLConnectorFilter();
// extends SslFilter and wraps a custom SSLContext
        connector.getFilterChain().addFirst("ssl", sslConnectorFilter);
        connector.connect(address);

Thanks in advance for your help.

Reply via email to