【问题标题】:Attribute Error: 'module' object has no attribute 'DTLSv1_METHOD'属性错误:“模块”对象没有属性“DTLSv1_METHOD”
【发布时间】:2017-02-20 19:30:33
【问题描述】:
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

【问题讨论】:

  • 你为什么认为SSL.DTLSv1_METHOD是一个东西?
  • 看起来该代码实际上不起作用。第一条评论是有人说他们很确定它不起作用。 docspyopenssl's GitHub repository 中没有出现这样的内容。
  • @user2357112 谢谢,你知道任何用于保护 udp 连接的 python 实现.. 我找不到吗?
  • 关于那个话题,我知道的和Google results 提供的一样多。

标签: python ssl openssl pyopenssl


【解决方案1】:

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 手册页。

【讨论】:

  • 嗨 .. 还是不行我试过 DTLS_method、DTLS_server_method 或 DTLS_client_method 还是一样
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-09-29
  • 2011-10-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-05-23
相关资源
最近更新 更多