Recompiling python with SSL support on ubuntu
I have built/installed Python 2.7 on my Ubuntu 10.04 and I just saw that SSL is not activated.
Do I have to rebuild Python ?
How can I rebuild it with SSL support and update my current install ?
I would not like to have a new install in parallel.
Trying to use oauth2:
>>> import oauth2
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.7/site-packages/oauth2/init.py", line 32, in import httplib2
File "/usr/local/lib/python2.7/site-packages/httplib2/init.py", line 801, in class HTTPSConnectionWithTimeout(httplib.HTTPSConnection):
AttributeError: 'module' object has no attribute 'HTTPSConnection'
Docs are telling
HTTPS support is only available if the socket module was compiled with SSL support.
So I wanted to activate SSL support
Trying to install pyOpenSSL
$ python setup.py build
Gives this
/usr/local/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'zip_safe'
warnings.warn(msg)
running build
running build_py
running build_ext
building 'OpenSSL.crypto' extension
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/local/include/python2.7 -c OpenSSL/crypto/crypto.c -o build/temp.linux-x86_64-2.7/OpenSSL/crypto/crypto.o
In file included from OpenSSL/crypto/crypto.h:17,
from OpenSSL/crypto/crypto.c:15:
OpenSSL/crypto/x509.h:17:25: error: openssl/ssl.h: No such file or directory
In file included from OpenSSL/crypto/crypto.h:17,
from OpenSSL/crypto/crypto.c:15:
OpenSSL/crypto/x509.h:25: error: expected specifier-qualifier-list before ‘X509’
OpenSSL/crypto/x509.h:29: error: expected declaration specifiers or ‘...’ before ‘ASN1_TIME’
OpenSSL/crypto/x509.h:30: error: expected declaration specifiers or ‘...’ before ‘ASN1_TIME’
In file included from OpenSSL/crypto/crypto.h:18,
from OpenSSL/crypto/crypto.c:15:
OpenSSL/crypto/x509name.h:27: error: expected specifier-qualifier-list before ‘X509_NAME’
In file included from OpenSSL/crypto/crypto.h:19,
from OpenSSL/crypto/crypto.c:15:
OpenSSL/crypto/netscape_spki.h:24: error: expected specifier-qualifier-list before ‘NETSCAPE_SPKI’
In file included from OpenSSL/crypto/crypto.h:20,
from OpenSSL/crypto/crypto.c:15:
OpenSSL/crypto/x509store.h:25: error: expected specifier-qualifier-list before ‘X509_STORE’
In file included from OpenSSL/crypto/crypto.h:21,
from OpenSSL/crypto/crypto.c:15:
OpenSSL/crypto/x509req.h:25: error: expected specifier-qualifier-list before ‘X509_REQ’
In file included from OpenSSL/crypto/crypto.h:22,
from OpenSSL/crypto/crypto.c:15:
OpenSSL/crypto/pkey.h:27: error: expected specifier-qualifier-list before ‘EVP_PKEY’
In file included from OpenSSL/crypto/crypto.h:23,
from OpenSSL/crypto/crypto.c:15:
OpenSSL/crypto/x509ext.h:16:28: error: openssl/x509v3.h: No such file or directory
In file included from OpenSSL/crypto/crypto.h:23,
from OpenSSL/crypto/crypto.c:15:
OpenSSL/crypto/x509ext.h:28: error: expected specifier-qualifier-list before ‘X509_EXTENSION’
In file included from OpenSSL/crypto/crypto.h:24,
from OpenSSL/crypto/crypto.c:15:
OpenSSL/crypto/pkcs7.h:15:27: error: openssl/pkcs7.h: No such file or directory
In file included from OpenSSL/crypto/crypto.h:24,
from OpenSSL/crypto/crypto.c:15:
OpenSSL/crypto/pkcs7.h:25: error: expected specifier-qualifier-list before ‘PKCS7’
In file included from OpenSSL/crypto/crypto.h:25,
from OpenSSL/crypto/crypto.c:15:
OpenSSL/crypto/pkcs12.h:14:28: error: openssl/pkcs12.h: No such file or directory
OpenSSL/crypto/pkcs12.h:15:26: error: openssl/asn1.h: No such file or directory
In file included from OpenSSL/crypto/crypto.h:25,
from OpenSSL/crypto/crypto.c:15:
OpenSSL/crypto/pkcs12.h:37: error: expected ‘)’ before ‘*’ token
In file included from OpenSSL/crypto/crypto.h:26,
from OpenSSL/crypto/crypto.c:15:
OpenSSL/crypto/crl.h:14: error: expected specifier-qualifier-list before ‘X509_CRL’
OpenSSL/crypto/crl.h:17: error: expected ‘)’ before ‘*’ token
In file included from OpenSSL/crypto/crypto.h:27,
from OpenSSL/crypto/crypto.c:15:
OpenSSL/crypto/revoked.h:12: error: expected specifier-qualifier-list before ‘X509_REVOKED’
OpenSSL/crypto/revoked.h:16: error: expected ‘)’ before ‘*’ token
In file included from OpenSSL/crypto/crypto.h:28,
from OpenSSL/crypto/crypto.c:15:
OpenSSL/crypto/../util.h:17:25: error: openssl/err.h: No such file or directory
In file included from OpenSSL/crypto/crypto.c:15:
OpenSSL/crypto/crypto.h:74: error: expected ‘)’ before ‘*’ token
OpenSSL/crypto/crypto.h:75: error: expected ‘)’ before ‘*’ token
OpenSSL/crypto/crypto.h:76: error: expected ‘)’ before ‘*’ token
OpenSSL/crypto/crypto.h:77: error: expected ‘)’ before ‘*’ token
OpenSSL/crypto/crypto.h:78: error: expected ‘)’ before ‘*’ token
OpenSSL/crypto/crypto.h:80: error: expected ‘)’ before ‘*’ token
OpenSSL/crypto/crypto.h:81: error: expected ‘)’ before ‘*’ token
OpenSSL/crypto/crypto.c: In function ‘crypto_load_privatekey’:
OpenSSL/crypto/crypto.c:78: error: expected ‘)’ before ‘*’ token
OpenSSL/crypto/crypto.c:82: error: ‘pem_password_cb’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:82: error: (Each undeclared identifier is reported only once
OpenSSL/crypto/crypto.c:82: error: for each function it appears in.)
OpenSSL/crypto/crypto.c:82: error: ‘cb’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:84: error: ‘BIO’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:84: error: ‘bio’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:85: error: ‘EVP_PKEY’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:85: error: ‘pkey’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:109: warning: implicit declaration of function ‘BIO_new_mem_buf’
OpenSSL/crypto/crypto.c:112: error: ‘X509_FILETYPE_PEM’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:113: warning: implicit declaration of function ‘PEM_read_bio_PrivateKey’
OpenSSL/crypto/crypto.c:116: error: ‘X509_FILETYPE_ASN1’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:117: warning: implicit declaration of function ‘d2i_PrivateKey_bio’
OpenSSL/crypto/crypto.c:122: warning: implicit declaration of function ‘BIO_free’
OpenSSL/crypto/crypto.c:133: warning: implicit declaration of function ‘crypto_PKey_New’
OpenSSL/crypto/crypto.c: In function ‘crypto_dump_privatekey’:
OpenSSL/crypto/crypto.c:157: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
OpenSSL/crypto/crypto.c:157: error: ‘cipher’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:159: error: ‘pem_password_cb’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:159: error: ‘cb’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:161: error: ‘BIO’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:161: error: ‘bio’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:162: error: ‘RSA’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:162: error: ‘rsa’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:176: warning: implicit declaration of function ‘EVP_get_cipherbyname’
OpenSSL/crypto/crypto.c:199: warning: implicit declaration of function ‘BIO_new’
OpenSSL/crypto/crypto.c:199: warning: implicit declaration of function ‘BIO_s_mem’
OpenSSL/crypto/crypto.c:202: error: ‘X509_FILETYPE_PEM’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:203: warning: implicit declaration of function ‘PEM_write_bio_PrivateKey’
OpenSSL/crypto/crypto.c:203: error: ‘crypto_PKeyObj’ has no member named ‘pkey’
OpenSSL/crypto/crypto.c:211: error: ‘X509_FILETYPE_ASN1’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:212: warning: implicit declaration of function ‘i2d_PrivateKey_bio’
OpenSSL/crypto/crypto.c:212: error: ‘crypto_PKeyObj’ has no member named ‘pkey’
OpenSSL/crypto/crypto.c:216: warning: implicit declaration of function ‘EVP_PKEY_get1_RSA’
OpenSSL/crypto/crypto.c:216: error: ‘crypto_PKeyObj’ has no member named ‘pkey’
OpenSSL/crypto/crypto.c:217: warning: implicit declaration of function ‘RSA_print’
OpenSSL/crypto/crypto.c:218: warning: implicit declaration of function ‘RSA_free’
OpenSSL/crypto/crypto.c:234: warning: implicit declaration of function ‘BIO_get_mem_data’
OpenSSL/crypto/crypto.c: In function ‘crypto_load_certificate’:
OpenSSL/crypto/crypto.c:252: error: expected ‘)’ before ‘*’ token
OpenSSL/crypto/crypto.c:255: error: ‘BIO’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:255: error: ‘bio’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:256: error: ‘X509’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:256: error: ‘cert’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:264: error: ‘X509_FILETYPE_PEM’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:265: warning: implicit declaration of function ‘PEM_read_bio_X509’
OpenSSL/crypto/crypto.c:268: error: ‘X509_FILETYPE_ASN1’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:269: warning: implicit declaration of function ‘d2i_X509_bio’
OpenSSL/crypto/crypto.c:285: warning: implicit declaration of function ‘crypto_X509_New’
OpenSSL/crypto/crypto.c: In function ‘crypto_dump_certificate’:
OpenSSL/crypto/crypto.c:302: error: ‘BIO’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:302: error: ‘bio’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:312: error: ‘X509_FILETYPE_PEM’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:313: warning: implicit declaration of function ‘PEM_write_bio_X509’
OpenSSL/crypto/crypto.c:313: error: ‘crypto_X509Obj’ has no member named ‘x509’
OpenSSL/crypto/crypto.c:316: error: ‘X509_FILETYPE_ASN1’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:317: warning: implicit declaration of function ‘i2d_X509_bio’
OpenSSL/crypto/crypto.c:317: error: ‘crypto_X509Obj’ has no member named ‘x509’
OpenSSL/crypto/crypto.c:321: warning: implicit declaration of function ‘X509_print_ex’
OpenSSL/crypto/crypto.c:321: error: ‘crypto_X509Obj’ has no member named ‘x509’
OpenSSL/crypto/crypto.c: In function ‘crypto_load_certificate_request’:
OpenSSL/crypto/crypto.c:355: error: expected ‘)’ before ‘*’ token
OpenSSL/crypto/crypto.c:358: error: ‘BIO’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:358: error: ‘bio’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:359: error: ‘X509_REQ’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:359: error: ‘req’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:367: error: ‘X509_FILETYPE_PEM’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:368: warning: implicit declaration of function ‘PEM_read_bio_X509_REQ’
OpenSSL/crypto/crypto.c:371: error: ‘X509_FILETYPE_ASN1’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:372: warning: implicit declaration of function ‘d2i_X509_REQ_bio’
OpenSSL/crypto/crypto.c:388: warning: implicit declaration of function ‘crypto_X509Req_New’
OpenSSL/crypto/crypto.c: In function ‘crypto_dump_certificate_request’:
OpenSSL/crypto/crypto.c:405: error: ‘BIO’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:405: error: ‘bio’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:415: error: ‘X509_FILETYPE_PEM’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:416: warning: implicit declaration of function ‘PEM_write_bio_X509_REQ’
OpenSSL/crypto/crypto.c:416: error: ‘crypto_X509ReqObj’ has no member named ‘x509_req’
OpenSSL/crypto/crypto.c:419: error: ‘X509_FILETYPE_ASN1’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:420: warning: implicit declaration of function ‘i2d_X509_REQ_bio’
OpenSSL/crypto/crypto.c:420: error: ‘crypto_X509ReqObj’ has no member named ‘x509_req’
OpenSSL/crypto/crypto.c:424: warning: implicit declaration of function ‘X509_REQ_print_ex’
OpenSSL/crypto/crypto.c:424: error: ‘crypto_X509ReqObj’ has no member named ‘x509_req’
OpenSSL/crypto/crypto.c: In function ‘crypto_load_crl’:
OpenSSL/crypto/crypto.c:460: error: ‘BIO’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:460: error: ‘bio’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:461: error: ‘X509_CRL’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:461: error: ‘crl’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:469: error: ‘X509_FILETYPE_PEM’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:470: warning: implicit declaration of function ‘PEM_read_bio_X509_CRL’
OpenSSL/crypto/crypto.c:473: error: ‘X509_FILETYPE_ASN1’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:474: warning: implicit declaration of function ‘d2i_X509_CRL_bio’
OpenSSL/crypto/crypto.c:489: warning: implicit declaration of function ‘crypto_CRL_New’
OpenSSL/crypto/crypto.c: In function ‘crypto_load_pkcs7_data’:
OpenSSL/crypto/crypto.c:505: error: ‘BIO’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:505: error: ‘bio’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:506: error: ‘PKCS7’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:506: error: ‘pkcs7’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:517: error: ‘X509_FILETYPE_PEM’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:518: warning: implicit declaration of function ‘PEM_read_bio_PKCS7’
OpenSSL/crypto/crypto.c:521: error: ‘X509_FILETYPE_ASN1’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:522: warning: implicit declaration of function ‘d2i_PKCS7_bio’
OpenSSL/crypto/crypto.c:541: warning: implicit declaration of function ‘crypto_PKCS7_New’
OpenSSL/crypto/crypto.c: In function ‘crypto_load_pkcs12’:
OpenSSL/crypto/crypto.c:557: error: ‘BIO’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:557: error: ‘bio’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:558: error: ‘PKCS12’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:558: error: ‘p12’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:564: warning: implicit declaration of function ‘d2i_PKCS12_bio’
OpenSSL/crypto/crypto.c:572: warning: implicit declaration of function ‘crypto_PKCS12_New’
OpenSSL/crypto/crypto.c: In function ‘crypto_X509_verify_cert_error_string’:
OpenSSL/crypto/crypto.c:592: warning: implicit declaration of function ‘X509_verify_cert_error_string’
OpenSSL/crypto/crypto.c:592: warning: assignment makes pointer from integer without a cast
OpenSSL/crypto/crypto.c: In function ‘crypto_sign’:
OpenSSL/crypto/crypto.c:623: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
OpenSSL/crypto/crypto.c:623: error: ‘digest’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:624: error: ‘EVP_MD_CTX’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:624: error: expected ‘;’ before ‘md_ctx’
OpenSSL/crypto/crypto.c:633: warning: implicit declaration of function ‘EVP_get_digestbyname’
OpenSSL/crypto/crypto.c:638: warning: implicit declaration of function ‘EVP_SignInit’
OpenSSL/crypto/crypto.c:638: error: ‘md_ctx’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:639: warning: implicit declaration of function ‘EVP_SignUpdate’
OpenSSL/crypto/crypto.c:641: warning: implicit declaration of function ‘EVP_SignFinal’
OpenSSL/crypto/crypto.c:641: error: ‘crypto_PKeyObj’ has no member named ‘pkey’
OpenSSL/crypto/crypto.c: In function ‘crypto_verify’:
OpenSSL/crypto/crypto.c:669: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
OpenSSL/crypto/crypto.c:669: error: ‘digest’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:670: error: ‘EVP_MD_CTX’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:670: error: expected ‘;’ before ‘md_ctx’
OpenSSL/crypto/crypto.c:671: error: ‘EVP_PKEY’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:671: error: ‘pkey’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:686: warning: implicit declaration of function ‘X509_get_pubkey’
OpenSSL/crypto/crypto.c:686: error: ‘crypto_X509Obj’ has no member named ‘x509’
OpenSSL/crypto/crypto.c:692: warning: implicit declaration of function ‘EVP_VerifyInit’
OpenSSL/crypto/crypto.c:692: error: ‘md_ctx’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:693: warning: implicit declaration of function ‘EVP_VerifyUpdate’
OpenSSL/crypto/crypto.c:694: warning: implicit declaration of function ‘EVP_VerifyFinal’
OpenSSL/crypto/crypto.c:695: warning: implicit declaration of function ‘EVP_PKEY_free’
OpenSSL/crypto/crypto.c: In function ‘locking_function’:
OpenSSL/crypto/crypto.c:741: error: ‘CRYPTO_LOCK’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c: In function ‘init_openssl_threads’:
OpenSSL/crypto/crypto.c:758: warning: implicit declaration of function ‘CRYPTO_num_locks’
OpenSSL/crypto/crypto.c:765: warning: implicit declaration of function ‘CRYPTO_set_id_callback’
OpenSSL/crypto/crypto.c:766: warning: implicit declaration of function ‘CRYPTO_set_locking_callback’
OpenSSL/crypto/crypto.c: In function ‘initcrypto’:
OpenSSL/crypto/crypto.c:814: warning: implicit declaration of function ‘ERR_load_crypto_strings’
OpenSSL/crypto/crypto.c:815: warning: implicit declaration of function ‘OpenSSL_add_all_algorithms’
OpenSSL/crypto/crypto.c:829: error: ‘crypto_X509_New’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:830: error: ‘crypto_X509Name_New’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:831: error: ‘crypto_X509Req_New’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:832: error: ‘crypto_X509Store_New’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:833: error: ‘crypto_PKey_New’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:835: error: ‘crypto_PKCS7_New’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:836: error: ‘crypto_NetscapeSPKI_New’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:848: error: ‘X509_FILETYPE_PEM’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:849: error: ‘X509_FILETYPE_ASN1’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:852: error: ‘EVP_PKEY_RSA’ undeclared (first use in this function)
OpenSSL/crypto/crypto.c:853: error: ‘EVP_PKEY_DSA’ undeclared (first use in this function)
error: command 'gcc' failed with exit status 1
To link custom built software with library you need to have C headers installed. In ubuntu they are in -dev packages (libname-dev).
In your particular case you need to install libssl-dev (apt-get install libssl-dev) and
- If you need SSL related functionality in standard library, then you should rebuild your python 2.7 installation.
- For custom library SSL support, just rebuild libraries (pip uninstall && pip install)
Try running easy_install pyopenssl
Or you can manually install the egg from https://launchpad.net/pyopenssl/
Once you extract the tarball, move into that folder and run:
python setup.py build
python setup.py install
And check if libssl-dev
is installed