After looking at the error line in _ssl.c, the problem was in fact with the certificate (the error message PEM lib was probably indicative enough of that). I set it via an environment variable, after doing this on the original certificate file: awk 1 ORS='\\n' star.example.org.cert Then in my Python...