Skip to content

Instantly share code, notes, and snippets.

View OnescuAlex-Vlad's full-sized avatar
🌍
Working from home

Onescu Alexandru Vlad OnescuAlex-Vlad

🌍
Working from home
  • Chisinau, Moldova
  • 07:18 (UTC +03:00)
View GitHub Profile
@erikbern
erikbern / use_pfx_with_requests.py
Last active April 24, 2024 13:48
How to use a .pfx file with Python requests – also works with .p12 files
import contextlib
import OpenSSL.crypto
import os
import requests
import ssl
import tempfile
@contextlib.contextmanager
def pfx_to_pem(pfx_path, pfx_password):
''' Decrypts the .pfx file to be used with requests. '''