gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 12:53:22 25 4
gpt4 key购买 nike

我使用以下源代码将 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com