Here's the code I use to start and stop SSL on an existing connection.
Charlie,
Here's the code I use to start and stop SSL on an existing connection.
Writing a basic client :
I just noticed how you did that, by providing the handle thru "sc->sockfd".
Does that mean you just do a connect to a server using a the OS standard means and than call this method ?
Also, before calling "SSL_connect" I do not see you provide the hostname anywhere. Neither the SSL_* equivalent to "BIO_set_conn_hostname", nor its TLS cousin, "SSL_set_tlsext_host_name".
Could you please explain ?
Also, before calling "SSL_connect" I do not see you provide the hostname
anywhere. Neither the SSL_* equivalent to "BIO_set_conn_hostname", nor
its
TLS cousin, "SSL_set_tlsext_host_name".
Could you please explain ?
I never really thought about it. I already have an open socket,
so host name isn't really relevant here. The name is in sc->sockname,
but I think I only use it when building error and debug messages.
Charlie,
Also, before calling "SSL_connect" I do not see you provide the hostname >>> anywhere. Neither the SSL_* equivalent to "BIO_set_conn_hostname", nor
its
TLS cousin, "SSL_set_tlsext_host_name".
Could you please explain ?
I never really thought about it. I already have an open socket,
so host name isn't really relevant here. The name is in sc->sockname,
but I think I only use it when building error and debug messages.
The thing is that the first SSL packet send normally contains the hostname - to help the server send the request packet to the right handler (there might be multiple virtual servers on a physical one).
I'll just have to try and see what actually gets send. Who knows, maybe OpenSSL extracts the target hostname from the socket.
All I know is that at this point I don't worry about the
host name, just the socket handle - and it Just Works.
Charlie,
All I know is that at this point I don't worry about the
host name, just the socket handle - and it Just Works.
I can't be satisfied with "it just works". I have the need to know *why* it (not) works. One of the drawbacks of being a hobbyist programmer I guess. :-)
s/hobbyist/inquisitive/
I'm a professional programmer and I really want to know how and
why things work (or don't work) too. It can save a lot of pain
down the road.
However, in this case all the TLS magic is being performed on
an already-opened socket. The host name (and port number) are
no longer relevant at this point; only the socket and SSL session
handles matter.
However, in this case all the TLS magic is being performed on
an already-opened socket. The host name (and port number) are
no longer relevant at this point; only the socket and SSL session
handles matter.
The problem is that the (only initial?) SSL communication with the server needs(?) that hostname too. And as I said, where does that "TLS magic" get it from ? Or is it that in your case its send as an empty string and you've been lucky the other side doesn't need it ?
Perhaps, but I've done SSL communication with lots of machines,
so either the host name isn't needed or I'm very lucky.
I haven't dug into the intricacies of the SSL handshake, and maybe
there's a host name is tucked in there somewhere.
The SSL code could be digging out the host name itself, e.g.
with gethostbyaddr().
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 379 |
Nodes: | 16 (2 / 14) |
Uptime: | 42:33:49 |
Calls: | 8,141 |
Calls today: | 4 |
Files: | 13,085 |
Messages: | 5,857,851 |