sockets - Boost 在 SSL 和 TLS 之间进行选择

标签 sockets ssl boost boost-asio

我使用以下源代码将 boost socket 与 SSL 结合使用:

ssl::context ctx(ssl::context::sslv23);
ctx.set_verify_mode(ssl::verify_peer);
ctx.load_verify_file("ca.pem");

我想知道 ssl::context::sslv23 是否也激活 TLS?

如果我想强制 TLS 连接(无 SSL 连接),它是否有效:

ctx.set_options( boost::asio::ssl::context::no_sslv2 | boost::asio::ssl::context::no_sslv3 );

仅 SSL 连接的相同问题:

ctx.set_options( boost::asio::ssl::context::no_tlsv1 );

谢谢

最佳答案

我相信您需要引用 OpenSSL 文档,因为 asio::ssl::context 是 SSL_CTX 的精简包装器。因此 ssl::context 构造函数调用 SSL_CTX_new()用适当的方法发挥作用。以及 ssl::context::set_options() 函数调用 SSL_CTX_set_options()功能。

特别是,对于 ssl::context::sslv23 方法,它将是:

SSLv23_method(void), SSLv23_server_method(void), SSLv23_client_method(void) A TLS/SSL connection established with these methods may understand the SSLv2, SSLv3, TLSv1, TLSv1.1 and TLSv1.2 protocols.

If the cipher list does not contain any SSLv2 ciphersuites (the default cipher list does not) or extensions are required (for example server name) a client will send out TLSv1 client hello messages including extensions and will indicate that it also understands TLSv1.1, TLSv1.2 and permits a fallback to SSLv3. A server will support SSLv3, TLSv1, TLSv1.1 and TLSv1.2 protocols. This is the best choice when compatibility is a concern.

If any SSLv2 ciphersuites are included in the cipher list and no extensions are required then SSLv2 compatible client hellos will be used by clients and SSLv2 will be accepted by servers. This is not recommended due to the insecurity of SSLv2 and the limited nature of the SSLv2 client hello prohibiting the use of extensions.

The list of protocols available can later be limited using the SSL_OP_NO_SSLv2, SSL_OP_NO_SSLv3, SSL_OP_NO_TLSv1, SSL_OP_NO_TLSv1_1 and SSL_OP_NO_TLSv1_2 options of the SSL_CTX_set_options() or SSL_set_options() functions. Using these options it is possible to choose e.g. SSLv23_server_method() and be able to negotiate with all possible clients, but to only allow newer protocols like TLSv1, TLSv1.1 or TLS v1.2.

Applications which never want to support SSLv2 (even is the cipher string is configured to use SSLv2 ciphersuites) can set SSL_OP_NO_SSLv2.

关于sockets - Boost 在 SSL 和 TLS 之间进行选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26388448/

相关文章:

linux - 在 Linux 中运行时指定 UDP 接收缓冲区大小

Java 服务器具有许多客户端连接而不会出现瓶颈

perl - 如何在 Perl 脚本的两个分支部分之间建立 IP 通信

html - 使用托管在其他站点上的 SSL 图像有任何风险吗?

c++ - 编译非常简单的 boost::spirit 语法时出错

c - AF_XDP : `BPF_MAP_TYPE_XSKMAP` only has entries with `Operation not supported`

wordpress - 将 1 个网页重定向到 HTTP 而不是 HTTPS

Java SSL 内存分配过多

c++ - Boost SSL 编译失败

c++ - 在 C++ 中包含目录时指定完整路径