python - 属性错误 : 'module' object has no attribute 'DTLSv1_METHOD'

标签 python ssl openssl pyopenssl

from OpenSSL import SSL
import sys, os, select, socket

cudp = SSL.Context(SSL.DTLSv1_METHOD)

错误:

Attribute Error: 'module' object has no attribute 'DTLSv1_METHOD'

python 2.7.6

OpenSSL 1.1.0e

最佳答案

Attribute Error: 'module' object has no attribute 'DTLSv1_METHOD'

我不确定 Python 提供了什么,但让我向您展示 OpenSSL 正在做什么。从下面开始,也许您可​​以尝试 DTLS_methodDTLS_server_methodDTLS_client_method

OpenSSL 的 GitHub:

$ git clone https://github.com/openssl/openssl.git
$ cd openssl

OpenSSL 1.1.0(大师提示):

$ git checkout master -f
$ grep -IR DTLS * | grep METHOD | grep ssl.h
...
include/openssl/ssl.h:# ifndef OPENSSL_NO_DTLS1_METHOD
include/openssl/ssl.h:# ifndef OPENSSL_NO_DTLS1_METHOD
include/openssl/ssl.h:DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *DTLSv1_method(void)) /* DTLSv1.0 */
include/openssl/ssl.h:DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *DTLSv1_server_method(void)) /* DTLSv1.0 */
include/openssl/ssl.h:DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *DTLSv1_client_method(void)) /* DTLSv1.0 */
include/openssl/ssl.h:# ifndef OPENSSL_NO_DTLS1_2_METHOD
include/openssl/ssl.h:DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *DTLSv1_2_method(void)) /* DTLSv1.2 */
include/openssl/ssl.h:DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *DTLSv1_2_server_method(void)) /* DTLSv1.2 */
include/openssl/ssl.h:DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *DTLSv1_2_client_method(void)) /* DTLSv1.2 */
include/openssl/ssl.h:__owur const SSL_METHOD *DTLS_method(void); /* DTLS 1.0 and 1.2 */
include/openssl/ssl.h:__owur const SSL_METHOD *DTLS_server_method(void); /* DTLS 1.0 and 1.2 */
include/openssl/ssl.h:__owur const SSL_METHOD *DTLS_client_method(void); /* DTLS 1.0 and 1.2 */

和 OpenSSL 1.0.2:

$ git checkout OpenSSL_1_0_2-stable
$ grep -IR DTLS * | grep METHOD | grep ssl.h
ssl/ssl.h:const SSL_METHOD *DTLSv1_method(void); /* DTLSv1.0 */
ssl/ssl.h:const SSL_METHOD *DTLSv1_server_method(void); /* DTLSv1.0 */
ssl/ssl.h:const SSL_METHOD *DTLSv1_client_method(void); /* DTLSv1.0 */
ssl/ssl.h:const SSL_METHOD *DTLSv1_2_method(void); /* DTLSv1.2 */
ssl/ssl.h:const SSL_METHOD *DTLSv1_2_server_method(void); /* DTLSv1.2 */
ssl/ssl.h:const SSL_METHOD *DTLSv1_2_client_method(void); /* DTLSv1.2 */
ssl/ssl.h:const SSL_METHOD *DTLS_method(void); /* DTLS 1.0 and 1.2 */
ssl/ssl.h:const SSL_METHOD *DTLS_server_method(void); /* DTLS 1.0 and 1.2 */
ssl/ssl.h:const SSL_METHOD *DTLS_client_method(void); /* DTLS 1.0 and 1.2 */

您可以在 docs/manpages.html 找到 OpenSSL 手册页。 .

关于python - 属性错误 : 'module' object has no attribute 'DTLSv1_METHOD' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42352810/

相关文章:

python - Matplotlib 热图 : Image rotated when heatmap plot over it

python - 将边添加到未加权的有向图效率?

python - 哪种策略最好 : saving a value as a field or just computing it on hand with a method

python - 如何为我的杆和楔形添加纹理?

openssl - X.509 : Private/Public Key

java - 是否可以将普通套接字更改为 SSLSocket?

c# - SslStream 充当服务器时是否使用 LocalCertificateSelectionCallback?

ruby-on-rails - 使用 godaddy 在 heroku 上添加 SSL 证书

php - 在 PHP 中使用 Openssl 验证 SSL 证书

php - 具有服务器端脚本语言(php、perl、python、shell...)的 RSA-PSSR