Java SSL socket layered over existing socket SSLSocketFactory: does it require a host parameter?

Viewed 91
1 Answers

Following the implementation in SSLSocketFactoryImpl, it would return new SSLSocketImpl, as in here you can see the following snippet of code

        if (peerHost == null || peerHost.isEmpty()) {
            boolean useNameService =
                    trustNameService && conContext.sslConfig.isClientMode;
            useImplicitHost(useNameService);
        } else {
            conContext.sslConfig.serverNames =
                    Utilities.addToSNIServerNameList(
                            conContext.sslConfig.serverNames, peerHost);
        }

(Note that peerHost is same as the host parameter)

So i think the point here is that if you don't provide the hostname, it would take a little more effort to lookup to do some stuff to get the hostname - You can follow useImplicitHost(useNameService) to see the logic in there in case the host is missing

Related