'Python Requests - verify ssl certificate without writing to local file

I want requests to verify the server's SSL certificate but I'm not willing to write it to the local file system and pass it the file path - rather I prefer providing the base64 of the certificate, or the StringIO stream.

Any suggestions on how to achieve this using the requests library?



Solution 1:[1]

This does not appear to be easily possible. requests uses urllib3 which seems to use the built in http.client library. The requests library doesn't support this out of the box, the urllib3 and http.client might but it wasn't clear to me. If there is another library that you're able to wrap for use in requests or if you can get those other libraries to do what you want, you can create a new "Transport Adapter" for requests. See here for more details: https://docs.python-requests.org/en/latest/user/advanced/#transport-adapters

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tim Ludwinski