Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Add PKCS#12 support to the requests library in a clean way, without monkey patching or temporary files
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.
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')
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
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_data
must be provided.pkcs12_data
is a byte string that contains the encrypted PKCS#12 certificate data.
pkcs12_filename
must be provided.pkcs12_password
is a byte string or unicode string that contains the password.
pkcs12_filename
or pkcs12_data
is provided.ssl_protocol
is a protocol version from the ssl
library.
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.
FAQs
Add PKCS#12 support to the requests library in a clean way, without monkey patching or temporary files
We found that requests-pkcs12 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.