Linking OpenSSL 1.1.0e installed manually to python2.7
OpenSSL 1.0.2 and OpenSSL 1.1.0 are not compatible at the API level. This means that you cannot simply relink Python against the new libssl and libcrypto. Instead you need to rebuild Python with the new libssl and libcrypto, as described in How do I compile Python 3.4 with custom OpenSSL? or Building Python with SSL support in non-standard location.
Building Python with SSL support in non-standard location
You need to edit Modules/Setup.dist
to specify the location of OpenSSL if it is not in the standard location. From Getting SSL Support in Python 2.5.1:
If you find yourself on a linux box needing ssl support in python (to
use a client in things like httplib.HTTPSConnection or
imaplib.IMAP4_SSL), then let me save you a couple of hours of hunting
around the web (of course if you have found this then that means
you've done some level hunting already!).You'll know if you need ssl support compiled into your python
installation if you get the following exception message:
AttributeError: 'module' object has no attribute 'ssl'In order to make that go away so you can continue happily slinging
python code, you'll need to first make sure you have OpenSSL
installed. By default it is installed from source at: /usr/local/sslIf that directory doesn't exist, then grab the source package.
Do the standard:
tar zxf openssl-0.9.8g.tar.gz
cd openssl-0.9.8g
./config
make
make install
Then grab the python sources for 2.5.1 and: tar zxf Python-2.5.1.tgz
&& cd Python-2.5.1Then you need to edit the Modules/Setup.dist:
204:# Socket module helper for SSL support; you must comment out the other
205:# socket line above, and possibly edit the SSL variable:
206:SSL=/usr/local/ssl
207:_ssl _ssl.c \
208: -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
209: -L$(SSL)/lib -lssl -lcrypto
If you installed OpenSSL in the default locations you can just
uncomment lines 206-209, then:./configure
make
make install
Then verify your installation with:
python /usr/local/lib/python2.5/test/test_socket_ssl.py
test_rude_shutdown ...
test_basic ...
test_timeout ...
Make sure the changes to Modules/Setup.dist
get picked up by cleaning the source root (e.g. make distclean
) and run configure
and make
again.
Related Topics
Converting Int to Bytes in Python 3
How to Install Python Packages on Windows
Removing Item from List Causes the List to Become Nonetype
Why am I Getting a Filenotfounderror
Environment Variable Differences When Using Paramiko
Lost Connection to MySQL Server During Query
Transpose Column to Row with Spark
Python -Intersection of Multiple Lists
Polling the Keyboard (Detect a Keypress) in Python
Unnest (Explode) a Pandas Series
Python: Calling 'List' on a Map Object Twice
Typeerror: a Bytes-Like Object Is Required, Not 'Str'
How to Detect Whether a Python Variable Is a Function
Execution of Python Code with -M Option or Not
How to Zip Two Differently Sized Lists, Repeating the Shorter List
Pygame Already Installed; However, Python Terminal Says "No Module Named 'Pygame' " (Ubuntu 20.04.1)