How to import OpenSSL in python -
i trying run simple code retrieve ssl certificate:
import ssl, socket #print ssl.get_server_certificate(('www.google.com', 443)) cert=ssl.get_server_certificate(('www.google.com', 443)) # openssl x509 = openssl.crypto.load_certificate(openssl.crypto.filetype_pem, cert) x509.get_subject().get_components()
but error saying:
traceback (most recent call last): file "c:\users\e\desktop\python\ssl\test.py", line 6, in <module> x509 = openssl.crypto.load_certificate(openssl.crypto.filetype_pem, cert) nameerror: name 'openssl' not defined
i aware have import openssl. not know how? , openssl from? downloaded module called pyopenssl https://pypi.python.org/pypi/pyopenssl contains 2 folders: pyopenssl-0.15.1.dist-info , openssl. when tried add import openssl or import pyopenssl errors. can explain please, how import these libraries or modules? should placed? if not in same directory of code file? how write path in import syntax?? please, help.
edit: when tried add from openssl import ssl
in code, got:
c:\users\e\desktop\python\ssl>test.py traceback (most recent call last): file "c:\users\e\desktop\python\ssl\test.py", line 2, in <module> openssl import ssl file "c:\users\e\desktop\python\ssl\openssl\__init__.py", line 8, in <module> openssl import rand, crypto, ssl file "c:\users\e\desktop\python\ssl\openssl\rand.py", line 9, in <module> 6 import integer_types _integer_types importerror: no module named 6
from tests:
from openssl import ssl
response edit: pip install pyopenssl
should have installed six. if you're trying install yourself, i'd not this, can install dependencies manually using pip install 6 cryptography
, import should work fine. if not, leave comment , i'll further investigation.
response comment: there instructions on installing pip on windows.
Comments
Post a Comment