On Mon, 12 Nov 2001, Eric Rescorla wrote:

> 1. I don't see how to make the switch-hit via a configuration file in
> 3.3.  If you set the "secure" variable for your virtual server,
> PoolTCPConnector tries to load the class named in socketFactoryName,
> or, if null, the class named in SSL_FACT (currently JSSE).  I've spent
> some time looking through the code and I don't see anything that
> would cause it to be set. Setting socketFactory in server.xml doesn't
> work. Have I missed something obvious or is this currently broken?

'secure' is a 'convenience' setting, so users don't have to type the full
name of the socket factory.

IMHO you should check if secure is true and do a class.forName() to find
if JSSE is present, same for pureTLS.

Setting the socketFactory can force one behavior or another, but for
'regular' users it should be possible to just set secure and the code
to detect what is available and use it.


> 2. Both JSSE and PureTLS derive almost all of their exceptions from
> IOException. If a server socket throws an IOException in accept() it
> will cause PoolTcpEndpoint.acceptSocket() to destroy the
> endpoint. This appears to be currently safe with JSSE because JSSE
> doesn't throw an exception when a handshake fails but instead returns
> a socket which throws an IOException when used.
>
> IMHO it's a mistake to rely on that behavior since it's kind of a
> misfeature in JSSE and this is already a problem with PureTLS, which
> does throw exceptions when the handshake fails. In the future Either
> PoolTcpEndpoint will have to be more forgiving or we'll need to wrap
> the socket so that it throws SocketException (which acceptSocket
> handles more cleanly).

One simple workaround could be to abstract acceptSocket() too ( i.e. make
it a method in ServerSocketFactory or SSLSupport).


> 3. Originally I'd intended to have ServerSockets return a class
> that subclassed SSLSupport. E.g.
>
>       class PureTLSSSLSocket extends SSLSocket implements SSLSupport {
>          ...
>       }
>
> Unfortunately, as I should have seen immediately this isn't very
> convenient. There's no way to make JSSE return a programmer-specified
> subclass of SSLSocket instead of SSLSocket. I can of course make
> PureTLS do so but that ties it inappropriately to Tomcat.


> This leaves us with two alternatives:
> (1) Create a wrapper class for SSLSocket:
>
>       class SSLSocketWrapper extends Socket implements SSLSupport {
>             Socket internal;
>
>             SSLSocketWrapper(Socket sock) {
>               internal=sock;
>             }
>
>             // Forwarding for all the relevant socket methods
>       }
>
> In general I hate class forwarding so I'm strongly tempted not to
> do this.

A don't like this either ( and I didn't like too much the idea
of returning a socket that implements SSLSupport either ).

What I would do is:

SSLSupport {
   String getFoo( Object socket, ... );

}

In other words, you pass the socket from which the SSLSupport object will
extract the information. ( it doens't have to be a socket - it can also be
an Ajp14Connection ). I think this is quite flexible and doesn't have too
much overhead

( but it's your choice, of course - you are writing the code :-)


> (2) Extend/generalize the socketFactory to include an SSLSupport
>     factory. This is actually pretty convenient since the relevant
>     section of code, Http10Interceptor already has access to
>     the socketFactory information via inheritance from
>     PoolTcpConnector. This could be done in several ways
>
> (a) Require that all SocketFactorys that produce SSL sockets implement
>
>     interface SSLSupportFactory {
>       public SSLSupport createSSLSupport(Socket socket);
>     }

That's fine too. For Ajp connectors we could have a different mechansim to
create the SSLSupport.


> (b) Have a second factory object in PoolTcpConnector and use reflection
>     to look it up. I don't much like this idea because it implies that
>     you can mix and match SocketFactories with SSLSupport classes
>     which of course you cannot.

Well, I like this idea - combined with the first one ( reversed ) :-)

I.e:
- SSLSupport act as a factory for SSLSocketFactories
- user will set only the SSLSupport class, which will create the socket
factory
- PoolTcpConnector will just have a method 'setSSLSupport'
- SSLSupport will be an abstract class, and will contain code to do
reflection and create the exact implementation
- Code using SSL will call SSLSupport.getSSLSupport() ( and maybe
setProperty, etc ), then set it on PoolTcpConnector ( if sockets are
used), etc.
- SSLSupport should be independent of tomcat ( you may noticed that
tomcat.util is compiled without any other tomcat class in classpath,
i.e. it can't have any dependencies on any internal tomcat class ! )


BTW, my personal preference is to avoid too many interfaces - in general I
prefer abstract classes if it is possible. At least until it becomes clear
we need a certain abstraction, otherwise we end up with something too
complex. For most people ( other than the author ) it is hard to
'navigate' around dozens of interfaces and base classes and hierarchies (
at least it is for me )

Costin




--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to