directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Niklas Gustavsson <nik...@protocol7.com>
Subject Adding SSLFilter on the fly
Date Wed, 10 Jan 2007 23:42:58 GMT
Hi

I'm trying to integrate MINA with Apache FtpServer, basically base 
FtpServer's socket handling on MINA. So far it's been a great 
experience. However, I just got stuck. It might very likely be an error 
on my side but I need some pointers :-)

The FTP AUTH command is sent by a client to tell the server that it 
wants to secure the FTP control socket with SSL. The flow is like this:

1. Client sends "AUTH TLS"
2. Server sends "234 Command AUTH okay; starting TLS connection."
3. Server secures the socket
4. Next client call is over the secure socket

Now, to implement this I add a SSLFilter at step 3. However, I seem to 
run into a condition where the response sent at step 2 sometimes end up 
in the, not yet initialized, SSLFilter. This results in:
java.lang.IllegalStateException
	at 
org.apache.mina.filter.SSLFilter.getSSLSessionHandler(SSLFilter.java:634)
	at org.apache.mina.filter.SSLFilter.messageReceived(SSLFilter.java:371)
	at 
org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(AbstractIoFilterChain.java:362)
	at 
org.apache.mina.common.support.AbstractIoFilterChain.access$1200(AbstractIoFilterChain.java:54)
	at 
org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageReceived(AbstractIoFilterChain.java:800)
	at 
org.apache.mina.common.support.AbstractIoFilterChain$HeadFilter.messageReceived(AbstractIoFilterChain.java:617)
	at 
org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(AbstractIoFilterChain..java:362)
	at 
org.apache.mina.common.support.AbstractIoFilterChain.fireMessageReceived(AbstractIoFilterChain.java:353)
	at 
org.apache.mina.transport.socket.nio.SocketIoProcessor.read(SocketIoProcessor.java:281)
	at 
org.apache.mina.transport.socket.nio.SocketIoProcessor.process(SocketIoProcessor.java:241)
	at 
org.apache.mina.transport.socket.nio.SocketIoProcessor.access$500(SocketIoProcessor.java:44)
	at 
org.apache.mina.transport.socket.nio.SocketIoProcessor$Worker.run(SocketIoProcessor.java:559)
	at 
org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:43)
	at java.lang.Thread.run(Thread.java:595)


 From my understanding, the response should already has been sent to the 
client but that seems not to be the case. The response (step 2) is sent as:
session.write(response).join();

Shouldn't the join() make that call wait until the write is completely 
done? If not, how would I otherwise ensure that the response has been 
sent before I add the SSL filter?

The full trace is attached.

Thanks!
/niklas

Mime
View raw message