I'm using Python 3.8 on macos. I also have Python 3.5 and 2.7 on this machine.
I'm trying to connect to adwords.google.com using the following snippet:
import ssl, socket
context = ssl.create_default_context()
conn = context.wrap_socket(
socket.socket(socket.AF_INET),
server_hostname="adwords.google.com"
)
conn.connect(("adwords.google.com", 443))
cert = conn.getpeercert()
but I always receive the following error:
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate
Running ssl.OPENSSL_VERSION I receive:
'OpenSSL 1.1.1g 21 Apr 2020'
What is weird is that if I run the same ssl connection snippet on either Python 3.5 or Python 2.7, the connection works. This happens ONLY on Python 3.8.
Why does that happen? Any ideas?