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

cudp = SSL.Context(SSL.DTLSv1_METHOD)

Error:

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

Python 2.7.6

OpenSSL 1.1.0e

mwweb
  • 7,625
  • 4
  • 19
  • 24
  • Why did you think `SSL.DTLSv1_METHOD` was a thing? – user2357112 Feb 20 '17 at 19:39
  • @user2357112 https://gist.github.com/manuels/8852953 – mwweb Feb 20 '17 at 19:40
  • It doesn't look like that code actually works. The first comment is some guy saying they're pretty sure it doesn't work. No such thing appears in the [docs](http://www.pyopenssl.org/en/stable/api/ssl.html) or in [pyopenssl's GitHub repository](https://github.com/pyca/pyopenssl/search?utf8=%E2%9C%93&q=DTLSv1_METHOD). – user2357112 Feb 20 '17 at 19:44
  • @user2357112 thanks, do you know any python implementation for securing udp connection.. i cant find any? – mwweb Feb 20 '17 at 19:46
  • On that topic, I only know as much as the [Google results](https://www.google.com/search?q=python+dtls) provide. – user2357112 Feb 20 '17 at 19:49
  • Did you compile Python with OpenSSL 1.0.2 or 1.1.0? Or is this a distro's version of Python? he reason I ask is no distros provide 1.1.0 that I am aware. Python is likely expecting 1.0.2 or 1.0.1. – jww Feb 20 '17 at 21:32

1 Answers1

-1

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

I'm not sure what Python is providing, but let me show you what OpenSSL is doing. From below, maybe you can try DTLS_method, DTLS_server_method or DTLS_client_method.

OpenSSL's GitHub:

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

OpenSSL 1.1.0 (tip of Master):

$ 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 */

And 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 */

You can find the OpenSSL man pages at docs/manpages.html.

jww
  • 97,681
  • 90
  • 411
  • 885
  • hi .. no still not work i tried DTLS_method, DTLS_server_method or DTLS_client_method still the same – mwweb Feb 22 '17 at 10:39