M2Crypto是否具有客户端服务器名称指示(SNI)支持?
问题描述:
我有一个使用M2Crypto编写的python SSL客户端,我想添加SNI支持。M2Crypto是否具有客户端服务器名称指示(SNI)支持?
Looks like使用OpenSSL,可以使用````SSL_set_tlsext_host_name(ssl,servername)'''但我没有看到该函数在M2Crypto API中公开。
我只是想念它还是有一些其他方式来做到这一点?
答
我查看了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错误/增强跟踪器。
谢谢桑德。你能添加一个链接到提交的跟踪问题,所以我可以按照它? – Von
以下是错误跟踪器的链接:https://bugzilla.osafoundation.org/show_bug.cgi?id = 13073 –