From 4f542ca3d4d02b675c4791034328c7f976cf0973 Mon Sep 17 00:00:00 2001 From: mayeut Date: Fri, 4 May 2018 23:55:28 +0200 Subject: [PATCH 1/2] Add test for TLS 1.2 support & valid certificates --- test/07_ssl/setup.py | 20 ++++++++++++++++++ test/07_ssl/spam.c | 48 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 test/07_ssl/setup.py create mode 100644 test/07_ssl/spam.c diff --git a/test/07_ssl/setup.py b/test/07_ssl/setup.py new file mode 100644 index 000000000..aa60f3821 --- /dev/null +++ b/test/07_ssl/setup.py @@ -0,0 +1,20 @@ +import ssl +import sys +from setuptools import setup, Extension + +if sys.version_info[0] == 2: + from urllib2 import urlopen +else: + from urllib.request import urlopen + +if sys.version_info[0:2] == (3, 3): + data = urlopen('https://www.nist.gov') +else: + context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2) + data = urlopen('https://www.nist.gov', context=context) + +setup( + name="spam", + ext_modules=[Extension('spam', sources=['spam.c'])], + version="0.1.0", +) diff --git a/test/07_ssl/spam.c b/test/07_ssl/spam.c new file mode 100644 index 000000000..d1ab0f225 --- /dev/null +++ b/test/07_ssl/spam.c @@ -0,0 +1,48 @@ +#include + +static PyObject * +spam_system(PyObject *self, PyObject *args) +{ + const char *command; + int sts; + + if (!PyArg_ParseTuple(args, "s", &command)) + return NULL; + sts = system(command); + return PyLong_FromLong(sts); +} + +/* Module initialization */ + +#if PY_MAJOR_VERSION >= 3 + #define MOD_INIT(name) PyMODINIT_FUNC PyInit_##name(void) + #define MOD_DEF(m, name, doc, methods, module_state_size) \ + static struct PyModuleDef moduledef = { \ + PyModuleDef_HEAD_INIT, name, doc, module_state_size, methods, }; \ + m = PyModule_Create(&moduledef); + #define MOD_RETURN(m) return m; +#else + #define MOD_INIT(name) PyMODINIT_FUNC init##name(void) + #define MOD_DEF(m, name, doc, methods, module_state_size) \ + m = Py_InitModule3(name, methods, doc); + #define MOD_RETURN(m) return; +#endif + +static PyMethodDef module_methods[] = { + {"system", (PyCFunction)spam_system, METH_VARARGS, + "Execute a shell command."}, + {NULL} /* Sentinel */ +}; + +MOD_INIT(spam) +{ + PyObject* m; + + MOD_DEF(m, + "spam", + "Example module", + module_methods, + -1) + + MOD_RETURN(m) +} From 1a910257bb65522586fe7006fdfce48c70c2ce69 Mon Sep 17 00:00:00 2001 From: mayeut Date: Sat, 5 May 2018 19:27:44 +0200 Subject: [PATCH 2/2] macOS: patch _ssl module on Python 3.4 & 3.5 --- cibuildwheel/macos.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index 4107c51f2..3d2ceaa8c 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -52,6 +52,10 @@ def call(args, env=None, cwd=None, shell=False): call(['curl', '-L', '-o', '/tmp/Python.pkg', config.url]) # install call(['sudo', 'installer', '-pkg', '/tmp/Python.pkg', '-target', '/']) + # patch open ssl + if config.version in ('3.4', '3.5'): + call(['curl', '-fsSLo', '/tmp/python-patch.tar.gz', 'https://github.com/mayeut/patch-macos-python-openssl/releases/download/v0.1.0/patch-macos-python-%s-openssl-v0.1.0.tar.gz' % config.version]) + call(['sudo', 'tar', '-C', '/Library/Frameworks/Python.framework/Versions/%s/' % config.version, '-xmf', '/tmp/python-patch.tar.gz']) env = os.environ.copy() env['PATH'] = os.pathsep.join([