2

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.

4

1 回答 1

2

如果服务器必须支持它,那么以给定的方式似乎是可能的。请参阅 SMTP。对于 SMTP 服务器,它以这种方式工作,其中前几个对话是在纯 TCP 中,然后是在 SSL/TLS 上。您可以使用 BIO_new_socket 将现有套接字绑定到 BIO,然后使用 SSL_set_bio 将此套接字设置为 SSL * 结构。

您可以找到许多 SSL 客户端示例。

于 2013-04-25T03:58:15.007 回答