Skip to content Skip to sidebar Skip to footer

How To Import Openssl In Python

I am trying to run this simple code to retrieve SSL certificate: import ssl, socket #print ssl.get_server_certificate(('www.google.com', 443)) cert=ssl.get_server_certificate(('ww

Solution 1:

From the tests:

fromOpenSSL importSSL

Response to the edit: pip install pyopenssl should have installed six. If you're trying to install yourself, I'd not do this, but you can install the dependencies manually using pip install six cryptography and then your import should work fine. If not, leave a comment and I'll do some further investigation.

Response to comment: There are instructions on installing pip on windows.

Solution 2:

Both these forms works.

import OpenSSL.SSL  # orfrom OpenSSL import SSL

You can also install using conda.

Please be aware that there are two python packages of similar names: openssl and pyopenssl.

  • Both has the same import name OpenSSL
  • Both are being used by many other packages. So it is not one supersede the other. Both are needed in general.
  • Install pyopenssl looks like will install openssl too.
  • For example, python itself uses openssl, while conda uses pyopenssl.

Here are the code snipes to see:

conda create -n x1 python=3.8 
conda list -n x1 | grep openssl # will see openssl

Post a Comment for "How To Import Openssl In Python"