Skip to content

Compile Python2 & Python3 with custom openssl.

First off, thanks to Scott Frazer and his post on:
http://stackoverflow.com/questions/23548188/how-do-i-compile-python-3-4-with-custom-openssl
which helped me build my Python2 and Python3 with openssl-1.0.2, thus supporting TLSv1.1 and TLSv1.2

The below is a modified version of the above URL, which worked for me.

# OpenSSL 1.0.2d
./config shared --prefix=/my/path/for/openssl --openssldir=/my/path/for/openssl/openssl
make
make install

# Python 2.7.10 and 3.4.3 Works with both
export LDFLAGS="-L/my/path/for/openssl/lib/ -Wl,-rpath=/my/path/for/openssl/lib/"
export LD_LIBRARY_PATH="/my/path/for/openssl/lib/"
export CPPFLAGS="-I/my/path/for/openssl/include -I/my/path/for/openssl/include/openssl"

Before starting the installation of Python I edited the Modules/Setup.dist uncommenting the following lines (not sure if it was necessary, but was suggested on several threads I came across):

SSL=/my/path/for/openssl/lib
_ssl _ssl.c \
    -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
    -L$(SSL)/lib -lssl -lcrypto

Finally:

./configure --prefix=/my/path/for/python
make
make install

…and you have your Python compiled with custom openssl.