Convert existing TCP socket into TLS using OpenSSL

匿名 (未验证) 提交于 2019-12-03 01:35:01

问题:

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:

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.



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!