requests_pkcs12 | Add PKCS # 12 support to the Python requests | TLS library
kandi X-RAY | requests_pkcs12 Summary
kandi X-RAY | requests_pkcs12 Summary
Add PKCS#12 support to the Python requests library in a clean way, without monkey patching or temporary files
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Generates a SSL certificate
- Wrapper for requests
- Handle GET requests
- Create an SSL context
- Raise a ValueError if the client certificate has not expired
- Creates a PyOpenSSL context
- Handles HEAD requests
- Handler for OPTIONS requests
- Generic DELETE method
- Make a patch request
- Makes a POST request
- Make a PUT request
requests_pkcs12 Key Features
requests_pkcs12 Examples and Code Snippets
from requests_pkcs12 import get
r = get('https://example.com/test', pkcs12_filename='clientcert.p12', pkcs12_password='correcthorsebatterystaple')
Community Discussions
Trending Discussions on requests_pkcs12
QUESTION
So I've writren a scraper that uses the requests_pkcs12-library and a .p12-cert.
Currently I'm making a lot a requests where I use it as described in the docs
...ANSWER
Answered 2020-Jul-04 at 06:29Yes, using a session may improve performance on client-side and reduce the server-side load as well.
Note that this has almost nothing to do with the requests_pkcs12
library, but is a generic mechanism of the requests
library.
The requests
manual states:
The Session object allows you to persist certain parameters across requests. It also persists cookies across all requests made from the Session instance, and will use urllib3’s connection pooling. So if you’re making several requests to the same host, the underlying TCP connection will be reused, which can result in a significant performance increase (see HTTP persistent connection).
The linked Wikipedia entry for HTTP persistent connection states:
Advantages
- ...
- Reduced CPU usage and round-trips because of fewer new connections and TLS handshakes.
And the Wikipedia section on TLS handshakes states:
Client-authenticated TLS handshake
...
- Negotiation Phase:
- ...
- The server sends a CertificateRequest message, to request a certificate from the client so that the connection can be mutually authenticated.
- ...
- The client responds with a Certificate message, which contains the client's certificate.
To summarize, using a requests
session leads to connection pooling which leads to fewer TCP connections and hence fewer TLS handshakes, which in turn means fewer client certificate authentications. Note that this is independent on how the client certificate was made available to requests
, whether in PKCS12 format (using requests_pkcs12
) or PEM format (using plain requests
).
QUESTION
I'm using Python 3.7.3 and the requests_pkcs12 library to scrape a website where I must pass a certificate and password, then download and extract zip files from links on the page. I've got the first part working fine. But when I try to read the files using urllib, I get an error.
...ANSWER
Answered 2020-Jan-30 at 00:59Answer was to not use urllib and instead use the same requests replacement that allows a pfx and password passed to it.
Last 2 lines:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install requests_pkcs12
You can use requests_pkcs12 like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page