This library adds PKCS#12 support to the Python
requests <http://python-requests.org>__ library.
It is a clean implementation: it uses neither monkey patching nor temporary files. Instead, it is integrated into
recommended by its authors: creating a custom
TransportAdapter, which provides a custom
This library is meant to be a transitional solution until this functionality is provided by
requests directly. However, that will take some time. See the
corresponding issue <https://github.com/requests/requests/issues/1573>__ for more details.
For simple one-off requests you can use this library as a drop-in replacement for the
.. code:: python
from requests_pkcs12 import get
r = get('https://example.com/test', pkcs12_filename='clientcert.p12', pkcs12_password='correcthorsebatterystaple')
If you are using
requests sessions <https://requests.readthedocs.io/en/master/user/advanced/>__, use the
.. code:: python
from requests import Session from requests_pkcs12 import Pkcs12Adapter
This library is available as
PyPI package <https://pypi.python.org/pypi/requests-pkcs12>__:
pip install requests-pkcs12
Alternatively, you can retrieve the latest development version via Git:
The following keyword arguments are supported:
pkcs12_filename is a byte string or unicode string that contains the file name of the encrypted PKCS#12 certificate.
pkcs12_datamust be provided.
pkcs12_data is a byte string that contains the encrypted PKCS#12 certificate data.
pkcs12_filenamemust be provided.
pkcs12_password is a byte string or unicode string that contains the password.
ssl_protocol is a protocol version from the
If you use these parameters, don’t use the built-in
cert parameter of
requests at the same time. However, do use the other parameters. In particular, do use
the "verify" parameter <http://docs.python-requests.org/en/master/user/advanced/#ssl-cert-verification>__ to verify the server-side certificate.