> Ok, but you can insert teh SslFilter *before* the proxyFilter. Once you
> get the ProxyConnector instance, get the connector and do :
 
Well, I am using a patched QuickFixJ version, in which the control flow is a 
bit different.

Here is an excerpt from the code they are using:


          CompositeIoFilterChainBuilder ioFilterChainBuilder = new 
CompositeIoFilterChainBuilder(
                    userIoFilterChainBuilder);

            boolean useProxy = proxyType != null && proxyPort > 0 &&
                                socketAddresses[0] instanceof InetSocketAddress;


            SslFilter sslFilter = null;
            if (sslEnabled) {
                boolean autoStart = !useProxy;
                sslFilter = installSslFilter(ioFilterChainBuilder, autoStart);
            }

            ioFilterChainBuilder.addLast(FIXProtocolCodecFactory.FILTER_NAME,
                    new ProtocolCodecFilter(new FIXProtocolCodecFactory()));

            if (useProxy) {
                SocketConnector socketConnector = new NioSocketConnector();
                socketConnector.setFilterChainBuilder(ioFilterChainBuilder);
                ioConnector = ProtocolFactory.createIoProxyConnector( 
socketConnector,
                        (InetSocketAddress) socketAddresses[0], new 
InetSocketAddress(proxyHost,
                                proxyPort), proxyType, proxyVersion, proxyUser, 
proxyPassword,
                        proxyDomain, proxyWorkstation);
            } else {
                ioConnector = 
ProtocolFactory.createIoConnector(socketAddresses[0]);
                ioConnector.setFilterChainBuilder(ioFilterChainBuilder);
            }

            ioHandler = new InitiatorIoHandler(fixSession, sslFilter, 
networkingOptions, eventHandlingStrategy);
        }

        private SslFilter installSslFilter(CompositeIoFilterChainBuilder 
ioFilterChainBuilder,
                                           boolean autoStart)
                throws GeneralSecurityException {
            SslFilter sslFilter = new 
SslFilter(SSLContextFactory.getInstance(keyStoreName,
                    keyStorePassword.toCharArray()), autoStart);
            if (enableProtocole != null)
                sslFilter.setEnabledProtocols(enableProtocole);
            if (cipherSuites != null)
                sslFilter.setEnabledCipherSuites(cipherSuites);
            sslFilter.setUseClientMode(true);
            ioFilterChainBuilder.addLast(SSLSupport.FILTER_NAME, sslFilter);
            return sslFilter;
        }


Sure, with a lot of time, I could possibly rewrite the code, to swap the 
positions of the filters in the filterchain.

But  I see little sense in it, since the code is working. The only problem I 
have, is that I get this deadlock after a few minutes or so.

At the moment, as a workaround, I simply disabled the "synchronized(handler) { 
... }" in ProxyFilter.writeData(),
I think for my special case this will work.

I don't think it is possible, that the filterchains are traverted in the same 
order for reading and writing.
  

 

Reply via email to