gh-95095: Use SSL_CTX_get_max_proto_version instead of SSL_CTX_ctrl (GH-95096)

The wrapper macros are more readable and match the form recommended in
the OpenSSL documentation. They also slightly less error-prone, as the
mapping of arguments to SSL_CTX_ctrl is not always clear. (Though in
this case it's straightforward.)
https://www.openssl.org/docs/man1.1.1/man3/SSL_CTX_get_max_proto_version.html
This commit is contained in:
David Benjamin 2022-07-21 11:44:30 -07:00 committed by GitHub
parent a6daaf2a13
commit 936f71e5d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -3515,7 +3515,7 @@ set_min_max_proto_version(PySSLContext *self, PyObject *arg, int what)
static PyObject *
get_minimum_version(PySSLContext *self, void *c)
{
int v = SSL_CTX_ctrl(self->ctx, SSL_CTRL_GET_MIN_PROTO_VERSION, 0, NULL);
int v = SSL_CTX_get_min_proto_version(self->ctx);
if (v == 0) {
v = PY_PROTO_MINIMUM_SUPPORTED;
}
@ -3531,7 +3531,7 @@ set_minimum_version(PySSLContext *self, PyObject *arg, void *c)
static PyObject *
get_maximum_version(PySSLContext *self, void *c)
{
int v = SSL_CTX_ctrl(self->ctx, SSL_CTRL_GET_MAX_PROTO_VERSION, 0, NULL);
int v = SSL_CTX_get_max_proto_version(self->ctx);
if (v == 0) {
v = PY_PROTO_MAXIMUM_SUPPORTED;
}