[ 
https://issues.apache.org/jira/browse/NET-593?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15329216#comment-15329216
 ] 

Jörg Weule commented on NET-593:
--------------------------------

The connect(String host, int port) has to set _hostname_ at the beginning, 
since _connectAction_() is calling the HostnameVerifier if isImplicit.
This means, public void connect(InetAddress host, int port) must not set 
_hostname_ to null at the first statement, because this is what the 
HostnameVerifier gets to verify.
The following is working:

public void connect(String hostname, int port)
    throws SocketException, IOException
    {
        //connect(InetAddress.getByName(hostname), port);
        _hostname_ = hostname;
        _socket_ = _socketFactory_.createSocket();
        if (receiveBufferSize != -1) {
            _socket_.setReceiveBufferSize(receiveBufferSize);
        }
        if (sendBufferSize != -1) {
            _socket_.setSendBufferSize(sendBufferSize);
        }
        _socket_.connect(new InetSocketAddress(InetAddress.getByName(hostname), 
port), connectTimeout);
        _connectAction_();
    }

Please change  public void connect(String hostname, int port, InetAddress 
localAddr, int localPort) in the same way:

    public void connect(String hostname, int port,
                        InetAddress localAddr, int localPort)
    {
        _hostname_ = hostname;
        _socket_ = _socketFactory_.createSocket();
        if (receiveBufferSize != -1) {
            _socket_.setReceiveBufferSize(receiveBufferSize);
        }
        if (sendBufferSize != -1) {
            _socket_.setSendBufferSize(sendBufferSize);
        }
        _socket_.bind(new InetSocketAddress(localAddr, localPort));
        _socket_.connect(new InetSocketAddress(InetAddress.getByName(hostname), 
port), connectTimeout);
        _connectAction_();
    }




> HostnameVerifier is called with ip addess instead of the provided hostname
> --------------------------------------------------------------------------
>
>                 Key: NET-593
>                 URL: https://issues.apache.org/jira/browse/NET-593
>             Project: Commons Net
>          Issue Type: Bug
>          Components: POP3, SMTP
>    Affects Versions: 3.4
>            Reporter: Jörg Weule
>
> When TLS is used (not StartTLS) on port 465, the HostnameVerifier is checking 
> for the ip address, not the hostname. This results in a failure on each 
> connection.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to