2
votes

I need some information about OpenSSL, TLS socket. First of i want to made a connection with server through TLS over TCP. Generally first create a TCP socket, then connect to server using the TCP socket, after that convert(before send or receive any data through TCP socket) the TCP socket into TLS.

My question is is it possible according to following way?

  1. Create TCP socket.

  2. Connect with server using TCP socket.

  3. Send and receive some data through TCP socket.

  4. Then convert the TCP socket into TLS.

    Note: I am using OpenSSL.

1

1 Answers

2
votes

It seems possible in the given way provided that the server must support it. See SMTP. It works in this way for SMTP server where first few conversation is in plain TCP then over SSL/TLS. You can bind an existing socket to a BIO using BIO_new_socket and then set this socket to SSL * structure using SSL_set_bio.

You can find many examples of SSL client.