summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--SWIG/_dh.i4
-rw-r--r--SWIG/_dsa.i4
-rw-r--r--SWIG/_rand.i4
-rw-r--r--SWIG/_rsa.i4
-rw-r--r--SWIG/_ssl.i8
-rw-r--r--setup.py27
6 files changed, 42 insertions, 9 deletions
diff --git a/SWIG/_dh.i b/SWIG/_dh.i
index 0fe3cfa..e4fed62 100644
--- a/SWIG/_dh.i
+++ b/SWIG/_dh.i
@@ -68,6 +68,10 @@ void gendh_callback(int p, int n, void *arg) {
DH *dh_generate_parameters(int plen, int g, PyObject *pyfunc) {
DH *dh;
+#if OPENSSL_VERSION_NUMBER >= 0x11100000L
+ PyErr_WarnEx(PyExc_DeprecationWarning,
+ "Function DH_generate_parameters has been deprecated.", 1))
+#endif
Py_INCREF(pyfunc);
dh = DH_generate_parameters(plen, g, gendh_callback, (void *)pyfunc);
Py_DECREF(pyfunc);
diff --git a/SWIG/_dsa.i b/SWIG/_dsa.i
index 1633bb6..ad712c4 100644
--- a/SWIG/_dsa.i
+++ b/SWIG/_dsa.i
@@ -54,6 +54,10 @@ void genparam_callback(int p, int n, void *arg) {
DSA *dsa_generate_parameters(int bits, PyObject *pyfunc) {
DSA *dsa;
+#if OPENSSL_VERSION_NUMBER >= 0x11100000L
+ PyErr_WarnEx(PyExc_DeprecationWarning,
+ "Function DSA_generate_parameters has been deprecated.", 1))
+#endif
Py_INCREF(pyfunc);
dsa = DSA_generate_parameters(bits, NULL, 0, NULL, NULL, genparam_callback, (void *)pyfunc);
Py_DECREF(pyfunc);
diff --git a/SWIG/_rand.i b/SWIG/_rand.i
index a26ca3e..3769826 100644
--- a/SWIG/_rand.i
+++ b/SWIG/_rand.i
@@ -86,6 +86,10 @@ PyObject *rand_pseudo_bytes(int n) {
PyMem_Free(blob);
return NULL;
}
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L
+ PyErr_WarnEx(PyExc_DeprecationWarning,
+ "Function RAND_pseudo_bytes has been deprecated.", 1);
+#endif
ret = RAND_pseudo_bytes(blob, n);
if (ret == -1) {
PyMem_Free(blob);
diff --git a/SWIG/_rsa.i b/SWIG/_rsa.i
index b1050be..1a3b182 100644
--- a/SWIG/_rsa.i
+++ b/SWIG/_rsa.i
@@ -443,6 +443,10 @@ PyObject *rsa_generate_key(int bits, unsigned long e, PyObject *pyfunc) {
PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */
Py_INCREF(pyfunc);
+#if OPENSSL_VERSION_NUMBER >= 0x11100000L
+ PyErr_WarnEx(PyExc_DeprecationWarning,
+ "Function RSA_generate_key has been deprecated.", 1))
+#endif
rsa = RSA_generate_key(bits, e, genrsa_callback, (void *)pyfunc);
Py_DECREF(pyfunc);
if (!rsa) {
diff --git a/SWIG/_ssl.i b/SWIG/_ssl.i
index 6a0d18f..631b6eb 100644
--- a/SWIG/_ssl.i
+++ b/SWIG/_ssl.i
@@ -65,11 +65,19 @@ extern const char *SSL_alert_desc_string(int);
extern const char *SSL_alert_desc_string_long(int);
#ifndef OPENSSL_NO_SSL3
+#if OPENSSL_VERSION_NUMBER >= 0x11100000L
+PyErr_WarnEx(PyExc_DeprecationWarning,
+ "Function SSLv3_method has been deprecated.", 1))
+#endif
%rename(sslv3_method) SSLv3_method;
extern SSL_METHOD *SSLv3_method(void);
#endif
%rename(sslv23_method) SSLv23_method;
extern SSL_METHOD *SSLv23_method(void);
+#if OPENSSL_VERSION_NUMBER >= 0x11100000L
+PyErr_WarnEx(PyExc_DeprecationWarning,
+ "Function TLSv1_method has been deprecated.", 1))
+#endif
%rename(tlsv1_method) TLSv1_method;
extern SSL_METHOD *TLSv1_method(void);
diff --git a/setup.py b/setup.py
index cf70fe5..afe469f 100644
--- a/setup.py
+++ b/setup.py
@@ -43,12 +43,13 @@ else:
_multiarch = sysconfig.get_config_var("MULTIARCH")
-def openssl_version(req_ver):
- # type: (str) -> bool
+def openssl_version(req_ver, required=False):
+ # type: (str, bool) -> bool
"""
Compare version of the installed OpenSSL with the maximum required version.
@param req_ver: required version as a str (e.g., '1.0.1')
+ @param required: whether we want bigger-or-equal or less-or-equal
@return: Boolean indicating whether the satisfying version of
OpenSSL has been installed.
"""
@@ -64,13 +65,16 @@ def openssl_version(req_ver):
if hasattr(out, 'decode'):
out = out.decode('utf8')
- ver_str = out.split()[1].strip(string.letters + string.punctuation +
+ ver_str = out.split()[1].strip(string.ascii_letters + string.punctuation +
string.whitespace)
if not ver_str:
raise OSError('Unknown format of openssl version -v output:\n%s' % out)
- return StrictVersion(ver_str) <= StrictVersion(req_ver)
+ if required:
+ return StrictVersion(ver_str) >= StrictVersion(req_ver)
+ else:
+ return StrictVersion(ver_str) <= StrictVersion(req_ver)
class _M2CryptoSDist(sdist.sdist):
@@ -232,13 +236,18 @@ def swig_version(req_ver):
return StrictVersion(ver_str) >= StrictVersion(req_ver)
-
+x_comp_args = set()
if sys.platform == 'darwin':
- x_comp_args = ["-Wno-deprecated-declarations"]
+ x_comp_args.add("-Wno-deprecated-declarations")
elif sys.platform == 'win32':
- x_comp_args = ['-DTHREADING', '-D_CRT_SECURE_NO_WARNINGS']
+ x_comp_args.update(['-DTHREADING', '-D_CRT_SECURE_NO_WARNINGS'])
else:
- x_comp_args = ['-DTHREADING']
+ x_comp_args.add('-DTHREADING')
+
+# We take care of deprecated functions in OpenSSL with our code, no need
+# to spam compiler output with it.
+if openssl_version('1.1.0', required=True):
+ x_comp_args.add("-Wno-deprecated-declarations")
# Don't try to run swig on the ancient platforms
@@ -250,7 +259,7 @@ else:
m2crypto = setuptools.Extension(name='M2Crypto._m2crypto',
sources=lib_sources,
- extra_compile_args=x_comp_args,
+ extra_compile_args=list(x_comp_args),
# Uncomment to build Universal Mac binaries
# extra_link_args =
# ['-Wl,-search_paths_first'],