Skip to content

Compile Python2 & Python3 with custom openssl.

First off, thanks to Scott Frazer and his post on:
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 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 _ssl.c \
    -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
    -L$(SSL)/lib -lssl -lcrypto


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

…and you have your Python compiled with custom openssl.