1# cf. https://github.com/pypa/manylinux/issues/53 2 3GOOD_SSL = "https://google.com" 4BAD_SSL = "https://self-signed.badssl.com" 5 6import sys 7 8 9print("Testing SSL certificate checking for Python:", sys.version) 10 11if sys.version_info[:2] < (2, 7) or sys.version_info[:2] < (3, 4): 12 print("This version never checks SSL certs; skipping tests") 13 sys.exit(0) 14 15if sys.version_info[0] >= 3: 16 from urllib.request import urlopen 17 18 EXC = OSError 19else: 20 from urllib import urlopen 21 22 EXC = IOError 23 24print(f"Connecting to {GOOD_SSL} should work") 25urlopen(GOOD_SSL) 26print("...it did, yay.") 27 28print(f"Connecting to {BAD_SSL} should fail") 29try: 30 urlopen(BAD_SSL) 31 # If we get here then we failed: 32 print("...it DIDN'T!!!!!11!!1one!") 33 sys.exit(1) 34except EXC: 35 print("...it did, yay.") 36