Le 27/01/16 17:33, Norbert Irmer a écrit :
> Hello,
>
> I am trying to patch QuickFIX/J to use SOCKS Proxy connections.
>
> I found a patch on the QuickFIX/J Jira (QFJ-285), which I used as a start,
> and which, after some
> tweaking, I got to work with Mina-2.0.10/Mina-2.0.11.
>
> The main problem, when doing so, was, that I had to disable the autostart
> feature of the SslFilter
> in order to build the filterchain (ProxyFilter, SslFilter, FixProtocolFilter)
> without exceptions, and there wasn't a public function
> to start the Ssl handshake later on (SslFilter.startSsl only works after the
> initial handshake, not if autostart=false).
>
> I solved the problem by making the function "SslFilter.initiateHandshake"
> public, and executing the following code
> in the event handler "AbstractProxyIoHandler. proxySessionOpened":
>
> @Override
> public void proxySessionOpened(IoSession session) throws Exception {
> log.info("proxySessionOpened called");
> if (sslFilter != null) {
> IoFilter.NextFilter nextFilter =
> session.getFilterChain().getNextFilter(sslFilter);
> sslFilter.initiateHandshake(nextFilter, session);
> }
> }
>
> Maybe you can incorporate the same change in the Mina code (making
> initiateHandshake public, I mean), or provide some other means
> to initiate the first SSL handshake, when autostart=false.
Norbert, I think a better idea would be to add this method in the
SslFilter class :
/**
* Initiate the SSL handshake. This can be invoked if you have set
the 'autoStart' to
* false when creating the SslFilter instance.
*
* @param session The session for which the SSL handshake should be done
* @throws SSLException If the handshake failed
*/
public void initiateHandshake(IoSession session) throws SSLException {
IoFilter.NextFilter nextFilter =
session.getFilterChain().getNextFilter(SslFilter.class);
initiateHandshake(nextFilter, session);
}
You can now call it from your handler doing :
@Override
public void proxySessionOpened(IoSession session) throws Exception {
log.info("proxySessionOpened called");
if (sslFilter != null) {
sslFilter.initiateHandshake(session);
}
}
That removes the burden of finding the next filter in the handler.
wdyt ?