Mathew
Mathew

Reputation: 13

How to get client's IP after SSL handshake in OpenSSL

The problem is that after doing this:

    SSL* ssl;
    ssl = SSL_new(ctx);
    SSL_set_fd(ssl, sock);
    int err = SSL_accept(ssl);

I can't get acces to client's socket 'sock', so I neither can get acces to client's IP. Is there anyway I can get it from SSL structure? Couldn't find that at docs.

Thanks.

Upvotes: 1

Views: 1562

Answers (1)

Steffen Ullrich
Steffen Ullrich

Reputation: 123330

There is no information about IP in the SSL structure and you can use SSL even without any IP address. You will find the necessary information with getpeername on the socket itself. In case you need to get the socket for the SSL object use SSL_get_fd.

Upvotes: 2

Related Questions