blob: 926ec7d1f1c69b303549b4ba1141a55952b0884f [file] [log] [blame]
Alex Gaynoraf82d5e2013-10-29 17:07:24 -07001.. hazmat::
Alex Gaynor0f7f7812013-09-30 10:52:36 -07002
Alex Gaynor8f42fe42013-12-24 13:15:52 -08003OpenSSL Backend
4===============
Donald Stuffte51fb932013-10-27 17:26:17 -04005
Alex Stapletonc368ac22013-12-31 13:43:38 +00006The `OpenSSL`_ C library.
Alex Gaynor6d02e2d2013-09-30 10:37:22 -07007
Alex Gaynorf8796b12013-12-13 20:28:55 -08008.. data:: cryptography.hazmat.backends.openssl.backend
Alex Gaynor6d02e2d2013-09-30 10:37:22 -07009
Paul Kehrer2502ce52014-01-18 09:32:47 -060010 This is the exposed API for the OpenSSL backend. It has one public attribute.
11
Paul Kehrercfa2d622014-01-19 14:01:25 -060012 .. attribute:: name
Paul Kehrer2502ce52014-01-18 09:32:47 -060013
Paul Kehrercfa2d622014-01-19 14:01:25 -060014 The string name of this backend: ``"openssl"``
Alex Gaynor6d02e2d2013-09-30 10:37:22 -070015
Alex Stapletone68d73e2013-12-31 14:00:38 +000016Using your own OpenSSL on Linux
17-------------------------------
18
19Python links to OpenSSL for its own purposes and this can sometimes cause
20problems when you wish to use a different version of OpenSSL with cryptography.
21If you want to use cryptography with your own build of OpenSSL you will need to
22make sure that the build is configured correctly so that your version of
23OpenSSL doesn't conflict with Python's.
24
25The options you need to add allow the linker to identify every symbol correctly
26even when multiple versions of the library are linked into the same program. If
27you are using your distribution's source packages these will probably be
28patched in for you already, otherwise you'll need to use options something like
Alex Gaynor917e82e2014-01-24 11:34:04 -060029this when configuring OpenSSL:
Alex Stapletone68d73e2013-12-31 14:00:38 +000030
Alex Gaynor917e82e2014-01-24 11:34:04 -060031.. code-block:: console
32
33 $ ./config -Wl,--version-script=openssl.ld -Wl,-Bsymbolic-functions -fPIC shared
Alex Stapletone68d73e2013-12-31 14:00:38 +000034
35You'll also need to generate your own ``openssl.ld`` file. For example::
36
37 OPENSSL_1.0.1F_CUSTOM {
38 global:
39 *;
40 };
41
42You should replace the version string on the first line as appropriate for your
43build.
44
Paul Kehrer57e280b2014-01-10 00:26:07 -060045Using your own OpenSSL on OS X
46------------------------------
47
48To link cryptography against a custom version of OpenSSL you'll need to set
Paul Kehrer017f0b02014-01-24 10:20:36 -060049``ARCHFLAGS``, ``LDFLAGS``, and ``CFLAGS``. OpenSSL can be installed via
Alex Gaynor917e82e2014-01-24 11:34:04 -060050`Homebrew`_:
Paul Kehrer57e280b2014-01-10 00:26:07 -060051
Alex Gaynor917e82e2014-01-24 11:34:04 -060052.. code-block:: console
Paul Kehrer017f0b02014-01-24 10:20:36 -060053
Alex Gaynor917e82e2014-01-24 11:34:04 -060054 $ brew install openssl
Paul Kehrer57e280b2014-01-10 00:26:07 -060055
Alex Gaynor917e82e2014-01-24 11:34:04 -060056Then install cryptography linking against the brewed version:
57
58.. code-block:: console
59
60 $ env ARCHFLAGS="-arch x86_64" LDFLAGS="-L/usr/local/opt/openssl/lib" CFLAGS="-I/usr/local/opt/openssl/include" pip install cryptography
Paul Kehrer8caeb8d2014-01-10 12:38:14 -060061
Paul Kehrer57e280b2014-01-10 00:26:07 -060062
Alex Gaynor6d02e2d2013-09-30 10:37:22 -070063.. _`OpenSSL`: https://www.openssl.org/
Paul Kehrer57e280b2014-01-10 00:26:07 -060064.. _`Homebrew`: http://brew.sh