@Override
    public CryptoSocket createClientCryptoSocket(SocketChannel channel, Spec spec) {
        if (useTlsWhenClient) {
            return tlsEngine.createClientCryptoSocket(channel, spec);
        } else {
            return new NullCryptoSocket(channel, false);
        }
    }
A crypto engine that supports both tls encrypted connections and
unencrypted connections. The use of tls for incoming connections is
auto-detected using clever heuristics. The use of tls for outgoing
connections is controlled by the useTlsWhenClient flag given to the
constructor.
jrt/src/com/yahoo/jrt/MaybeTlsCryptoEngine.java