【问题标题】:Does M2Crypto have client-side Server Name Indication (SNI) support?M2Crypto 是否支持客户端服务器名称指示 (SNI)?
【发布时间】:2011-12-19 04:18:18
【问题描述】:

我有一个使用 M2Crypto 编写的 python SSL 客户端,我想添加SNI 支持。

Looks like 与 OpenSSL 一起使用 ```SSL_set_tlsext_host_name(ssl, servername)''' 但我没有看到该函数在 M2Crypto API 中公开。

我只是想念它还是有其他方法可以做到这一点?

【问题讨论】:

    标签: m2crypto sni


    【解决方案1】:

    我查看了 M2Crypto SVN 存储库中的最新代码,并且(还)不支持 SNI。我也需要 SNI,所以本着真正的开源精神,我为它写了一个补丁 :-)

    添加它的补丁其实很简单:

    Index: SWIG/_ssl.i
    ===================================================================
    --- SWIG/_ssl.i (revision 739)
    +++ SWIG/_ssl.i (working copy)
    @@ -14,6 +14,7 @@
     #include <openssl/bio.h>
     #include <openssl/dh.h>
     #include <openssl/ssl.h>
    +#include <openssl/tls1.h>
     #include <openssl/x509.h>
     %}
    
    @@ -375,6 +376,10 @@
         return SSL_get_mode(ssl);
     }
    
    +long ssl_set_tlsext_host_name(SSL *ssl, const char *name) {
    +    return SSL_set_tlsext_host_name(ssl, name);
    +}
    +
     void ssl_set_client_CA_list_from_file(SSL *ssl, const char *ca_file) {
         SSL_set_client_CA_list(ssl, SSL_load_client_CA_file(ca_file));
     }
    Index: M2Crypto/SSL/Connection.py
    ===================================================================
    --- M2Crypto/SSL/Connection.py  (revision 739)
    +++ M2Crypto/SSL/Connection.py  (working copy)
    @@ -359,3 +359,7 @@
    
         def set_post_connection_check_callback(self, postConnectionCheck):
             self.postConnectionCheck = postConnectionCheck
    +
    +    def set_tlsext_host_name(self, name):
    +        "Set the requested hostname for the SNI (Server Name Indication) extension"
    +        m2.ssl_set_tlsext_host_name(self.ssl, name)
    

    这当然也已提交给 M2Crypto 错误/增强跟踪器。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-23
    • 2022-12-11
    • 2012-07-26
    • 2014-01-18
    • 2017-05-23
    • 1970-01-01
    相关资源
    最近更新 更多