Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2427b50

Browse files
committed
Issue #8813: X509_VERIFY_PARAM is only available on OpenSSL 0.9.8+
The patch removes the verify_flags feature on Mac OS X 10.4 with OpenSSL 0.9.7l 28 Sep 2006.
1 parent 4a281a1 commit 2427b50

3 files changed

Lines changed: 18 additions & 0 deletions

File tree

Doc/library/ssl.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,6 +1126,7 @@ to speed up repeated connections from the same clients.
11261126
The flags for certificate verification operations. You can set flags like
11271127
:data:`VERIFY_CRL_CHECK_LEAF` by ORing them together. By default OpenSSL
11281128
does neither require nor verify certificate revocation lists (CRLs).
1129+
Available only with openssl version 0.9.8+.
11291130

11301131
.. versionadded:: 3.4
11311132

Lib/test/test_ssl.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ def no_sslv2_implies_sslv3_hello():
8282
# 0.9.7h or higher
8383
return ssl.OPENSSL_VERSION_INFO >= (0, 9, 7, 8, 15)
8484

85+
def have_verify_flags():
86+
# 0.9.8 or higher
87+
return ssl.OPENSSL_VERSION_INFO >= (0, 9, 8, 0, 15)
88+
8589
def asn1time(cert_time):
8690
# Some versions of OpenSSL ignore seconds, see #18207
8791
# 0.9.8.i
@@ -667,6 +671,8 @@ def test_verify_mode(self):
667671
with self.assertRaises(ValueError):
668672
ctx.verify_mode = 42
669673

674+
@unittest.skipUnless(have_verify_flags(),
675+
"verify_flags need OpenSSL > 0.9.8")
670676
def test_verify_flags(self):
671677
ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
672678
# default value by OpenSSL
@@ -1809,6 +1815,8 @@ def test_getpeercert(self):
18091815
self.assertLess(before, after)
18101816
s.close()
18111817

1818+
@unittest.skipUnless(have_verify_flags(),
1819+
"verify_flags need OpenSSL > 0.9.8")
18121820
def test_crl_check(self):
18131821
if support.verbose:
18141822
sys.stdout.write("\n")

Modules/_ssl.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,11 @@ static unsigned int _ssl_locks_count = 0;
198198
# define OPENSSL_NO_COMP
199199
#endif
200200

201+
/* X509_VERIFY_PARAM got added to OpenSSL in 0.9.8 */
202+
#if OPENSSL_VERSION_NUMBER >= 0x0090800fL
203+
# define HAVE_OPENSSL_VERIFY_PARAM
204+
#endif
205+
201206

202207
typedef struct {
203208
PyObject_HEAD
@@ -2230,6 +2235,7 @@ set_verify_mode(PySSLContext *self, PyObject *arg, void *c)
22302235
return 0;
22312236
}
22322237

2238+
#ifdef HAVE_OPENSSL_VERIFY_PARAM
22332239
static PyObject *
22342240
get_verify_flags(PySSLContext *self, void *c)
22352241
{
@@ -2267,6 +2273,7 @@ set_verify_flags(PySSLContext *self, PyObject *arg, void *c)
22672273
}
22682274
return 0;
22692275
}
2276+
#endif
22702277

22712278
static PyObject *
22722279
get_options(PySSLContext *self, void *c)
@@ -3088,8 +3095,10 @@ get_ca_certs(PySSLContext *self, PyObject *args, PyObject *kwds)
30883095
static PyGetSetDef context_getsetlist[] = {
30893096
{"options", (getter) get_options,
30903097
(setter) set_options, NULL},
3098+
#ifdef HAVE_OPENSSL_VERIFY_PARAM
30913099
{"verify_flags", (getter) get_verify_flags,
30923100
(setter) set_verify_flags, NULL},
3101+
#endif
30933102
{"verify_mode", (getter) get_verify_mode,
30943103
(setter) set_verify_mode, NULL},
30953104
{NULL}, /* sentinel */

0 commit comments

Comments
 (0)