changeset: 94856:37da00170836 branch: 2.7 parent: 94849:371cf371a6a1 user: Benjamin Peterson date: Wed Mar 04 22:11:12 2015 -0500 files: Misc/NEWS Modules/_ssl.c description: enable X509_V_FLAG_TRUSTED_FIRST when possible (closes #23476) diff -r 371cf371a6a1 -r 37da00170836 Misc/NEWS --- a/Misc/NEWS Wed Mar 04 20:51:55 2015 +0100 +++ b/Misc/NEWS Wed Mar 04 22:11:12 2015 -0500 @@ -18,6 +18,9 @@ Library ------- +- Issue #23476: In the ssl module, enable OpenSSL's X509_V_FLAG_TRUSTED_FIRST + flag on certificate stores when it is available. + - Issue #23576: Avoid stalling in SSL reads when EOF has been reached in the SSL layer but the underlying connection hasn't been closed. diff -r 371cf371a6a1 -r 37da00170836 Modules/_ssl.c --- a/Modules/_ssl.c Wed Mar 04 20:51:55 2015 +0100 +++ b/Modules/_ssl.c Wed Mar 04 22:11:12 2015 -0500 @@ -2072,6 +2072,15 @@ sizeof(SID_CTX)); #undef SID_CTX +#ifdef X509_V_FLAG_TRUSTED_FIRST + { + /* Improve trust chain building when cross-signed intermediate + certificates are present. See https://bugs.python.org/issue23476. */ + X509_STORE *store = SSL_CTX_get_cert_store(self->ctx); + X509_STORE_set_flags(store, X509_V_FLAG_TRUSTED_FIRST); + } +#endif + return (PyObject *)self; }