Skip to content

Commit af2b8f6

Browse files
authored
gh-113332: Simplify calls to SSL_(CTX_)set_verify in _ssl.c (#113333)
_ssl.c currently tries to preserve the verification callback, but at no point does it ever set one. Just pass in NULL.
1 parent 2b53c76 commit af2b8f6

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

Modules/_ssl.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -893,10 +893,8 @@ newPySSLSocket(PySSLContext *sslctx, PySocketSockObject *sock,
893893
* only in combination with SSL_VERIFY_PEER flag. */
894894
int mode = SSL_get_verify_mode(self->ssl);
895895
if (mode & SSL_VERIFY_PEER) {
896-
int (*verify_cb)(int, X509_STORE_CTX *) = NULL;
897-
verify_cb = SSL_get_verify_callback(self->ssl);
898896
mode |= SSL_VERIFY_POST_HANDSHAKE;
899-
SSL_set_verify(self->ssl, mode, verify_cb);
897+
SSL_set_verify(self->ssl, mode, NULL);
900898
}
901899
} else {
902900
/* client socket */
@@ -2997,7 +2995,6 @@ static int
29972995
_set_verify_mode(PySSLContext *self, enum py_ssl_cert_requirements n)
29982996
{
29992997
int mode;
3000-
int (*verify_cb)(int, X509_STORE_CTX *) = NULL;
30012998

30022999
switch(n) {
30033000
case PY_SSL_CERT_NONE:
@@ -3018,9 +3015,7 @@ _set_verify_mode(PySSLContext *self, enum py_ssl_cert_requirements n)
30183015
/* bpo-37428: newPySSLSocket() sets SSL_VERIFY_POST_HANDSHAKE flag for
30193016
* server sockets and SSL_set_post_handshake_auth() for client. */
30203017

3021-
/* keep current verify cb */
3022-
verify_cb = SSL_CTX_get_verify_callback(self->ctx);
3023-
SSL_CTX_set_verify(self->ctx, mode, verify_cb);
3018+
SSL_CTX_set_verify(self->ctx, mode, NULL);
30243019
return 0;
30253020
}
30263021

0 commit comments

Comments
 (0)