Skip to content

Commit 46f8249

Browse files
committed
travis: Test SSL using ssl-check.py script copied from manylinux
See https://github.com/pypa/manylinux/blob/master/docker/build_scripts/ssl-check.py
1 parent f817624 commit 46f8249

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ cache:
2626

2727
before_install:
2828
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then mkdir $HOME/bin; ln -s $(which pip2) $HOME/bin/pip; ln -s $(which python2) $HOME/bin/python; fi
29+
- python scripts/ssl-check.py
2930
- python -m pip install --disable-pip-version-check --upgrade pip
3031
- pip install -U scikit-ci scikit-ci-addons
3132
- ci_addons --install ../addons

scripts/ssl-check.py

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

0 commit comments

Comments
 (0)