requests-pkcs12


Namerequests-pkcs12 JSON
Version 1.25 PyPI version JSON
download
home_pagehttps://github.com/m-click/requests_pkcs12
SummaryAdd PKCS#12 support to the requests library in a clean way, without monkey patching or temporary files
upload_time2024-06-07 14:08:54
maintainerNone
docs_urlNone
authorVolker Diels-Grabsch
requires_python>=3.7
licenseISC
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            PKCS#12 support for requests
============================

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 unencrypted temporary files. Instead, it is integrated into ``requests`` as
recommended by its authors: creating a custom ``TransportAdapter``, which provides a custom ``SSLContext``.

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/2519>`__ for more details.

Usage
-----

For simple one-off requests you can use this library as a drop-in replacement for the ``requests`` library:

.. 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 ``Pkcs12Adapter``:

.. code:: python

   from requests import Session
   from requests_pkcs12 import Pkcs12Adapter

   with Session() as s:
       s.mount('https://example.com', Pkcs12Adapter(pkcs12_filename='clientcert.p12', pkcs12_password='correcthorsebatterystaple'))
       r = s.get('https://example.com/test')

Installation
------------

This library is available as `PyPI package <https://pypi.org/project/requests-pkcs12/>`__:

::

   pip install requests-pkcs12

Alternatively, you can retrieve the latest development version via Git:

::

   git clone https://github.com/m-click/requests_pkcs12

Arguments
---------

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.

   -  Either this argument or ``pkcs12_data`` must be provided.

-  ``pkcs12_data`` is a byte string that contains the encrypted PKCS#12 certificate data.

   -  Either this argument or ``pkcs12_filename`` must be provided.

-  ``pkcs12_password`` is a byte string or unicode string that contains the password.

   -  This argument must be provided whenever ``pkcs12_filename`` or ``pkcs12_data`` is provided.

-  ``ssl_protocol`` is a protocol version from the ``ssl`` library.

   -  This argument is optional and defaults to ``ssl.PROTOCOL_TLS``.

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.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/m-click/requests_pkcs12",
    "name": "requests-pkcs12",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": null,
    "author": "Volker Diels-Grabsch",
    "author_email": "volker.diels-grabsch@m-click.aero",
    "download_url": "https://files.pythonhosted.org/packages/de/c3/374d483894419d9ab359bc450a8d6bb00155df832662109dd6721129b07d/requests_pkcs12-1.25.tar.gz",
    "platform": null,
    "description": "PKCS#12 support for requests\n============================\n\nThis library adds PKCS#12 support to the Python `requests <http://python-requests.org>`__ library.\n\nIt is a **clean implementation**: it uses neither monkey patching nor unencrypted temporary files. Instead, it is integrated into ``requests`` as\nrecommended by its authors: creating a custom ``TransportAdapter``, which provides a custom ``SSLContext``.\n\nThis 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/2519>`__ for more details.\n\nUsage\n-----\n\nFor simple one-off requests you can use this library as a drop-in replacement for the ``requests`` library:\n\n.. code:: python\n\n   from requests_pkcs12 import get\n\n   r = get('https://example.com/test', pkcs12_filename='clientcert.p12', pkcs12_password='correcthorsebatterystaple')\n\nIf you are using `requests sessions <https://requests.readthedocs.io/en/master/user/advanced/>`__, use the ``Pkcs12Adapter``:\n\n.. code:: python\n\n   from requests import Session\n   from requests_pkcs12 import Pkcs12Adapter\n\n   with Session() as s:\n       s.mount('https://example.com', Pkcs12Adapter(pkcs12_filename='clientcert.p12', pkcs12_password='correcthorsebatterystaple'))\n       r = s.get('https://example.com/test')\n\nInstallation\n------------\n\nThis library is available as `PyPI package <https://pypi.org/project/requests-pkcs12/>`__:\n\n::\n\n   pip install requests-pkcs12\n\nAlternatively, you can retrieve the latest development version via Git:\n\n::\n\n   git clone https://github.com/m-click/requests_pkcs12\n\nArguments\n---------\n\nThe following keyword arguments are supported:\n\n-  ``pkcs12_filename`` is a byte string or unicode string that contains the file name of the encrypted PKCS#12 certificate.\n\n   -  Either this argument or ``pkcs12_data`` must be provided.\n\n-  ``pkcs12_data`` is a byte string that contains the encrypted PKCS#12 certificate data.\n\n   -  Either this argument or ``pkcs12_filename`` must be provided.\n\n-  ``pkcs12_password`` is a byte string or unicode string that contains the password.\n\n   -  This argument must be provided whenever ``pkcs12_filename`` or ``pkcs12_data`` is provided.\n\n-  ``ssl_protocol`` is a protocol version from the ``ssl`` library.\n\n   -  This argument is optional and defaults to ``ssl.PROTOCOL_TLS``.\n\nIf you use these parameters, don\u2019t 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.\n",
    "bugtrack_url": null,
    "license": "ISC",
    "summary": "Add PKCS#12 support to the requests library in a clean way, without monkey patching or temporary files",
    "version": "1.25",
    "project_urls": {
        "Homepage": "https://github.com/m-click/requests_pkcs12"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "15f11e64b080592f3283ae982d58c756655863d5fe2658e410426983afe93167",
                "md5": "245b955a3dc96f747e197d28d4e37c47",
                "sha256": "94fbd01958f6386198be04a1cb6f2f0c86bd2d89e0bf6fe5d09cfba874f23936"
            },
            "downloads": -1,
            "filename": "requests_pkcs12-1.25-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "245b955a3dc96f747e197d28d4e37c47",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 6066,
            "upload_time": "2024-06-07T14:08:52",
            "upload_time_iso_8601": "2024-06-07T14:08:52.842305Z",
            "url": "https://files.pythonhosted.org/packages/15/f1/1e64b080592f3283ae982d58c756655863d5fe2658e410426983afe93167/requests_pkcs12-1.25-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dec3374d483894419d9ab359bc450a8d6bb00155df832662109dd6721129b07d",
                "md5": "e2fdafec502143e757cecec03c776426",
                "sha256": "39d64144d9443c29fd7e9d4c33f6bcb8cda5ceedcb953030d6ea847f1889b410"
            },
            "downloads": -1,
            "filename": "requests_pkcs12-1.25.tar.gz",
            "has_sig": false,
            "md5_digest": "e2fdafec502143e757cecec03c776426",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 5413,
            "upload_time": "2024-06-07T14:08:54",
            "upload_time_iso_8601": "2024-06-07T14:08:54.501306Z",
            "url": "https://files.pythonhosted.org/packages/de/c3/374d483894419d9ab359bc450a8d6bb00155df832662109dd6721129b07d/requests_pkcs12-1.25.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-07 14:08:54",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "m-click",
    "github_project": "requests_pkcs12",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "requests-pkcs12"
}
        
Elapsed time: 0.44736s