8000 Use SSL_CTX_get_max_proto_version instead of SSL_CTX_ctrl · Issue #95095 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

Use SSL_CTX_get_max_proto_version instead of SSL_CTX_ctrl #95095

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
davidben opened this issue Jul 21, 2022 · 2 comments
Closed

Use SSL_CTX_get_max_proto_version instead of SSL_CTX_ctrl #95095

davidben opened this issue Jul 21, 2022 · 2 comments
Assignees
Labels
3.10 only security fixes 3.11 only security fixes 3.12 only security fixes type-bug An unexpected behavior, bug, or error

Comments

@davidben
Copy link
Contributor

Filing this since the devguide says to attach a GH issue to each PR. I'll upload a PR shortly to goes with it.

CPython uses SSL_CTX_ctrl(SSL_CTRL_GET_MAX_PROTO_VERSION) to query the maximum version, but it's cleaner to use the wrapper macro, SSL_CTX_get_max_proto_version. This is the version that's documented by OpenSSL and is easier to read.
https://www.openssl.org/docs/man1.1.1/man3/SSL_CTX_get_max_proto_version.html

The macros are also slightly safer since you're less likely to mess up the larg/parg calling convention. If OpenSSL ever does openssl/openssl#1319, it will also be more type-safe. (Also I work on BoringSSL, which has done just that, so fixing this makes life easier for us. But I think this change is good independent of BoringSSL.)

@davidben davidben added the type-bug An unexpected behavior, bug, or error label Jul 21, 2022
davidben added a commit to davidben/cpython that referenced this issue Jul 21, 2022
…ctrl

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
@tiran
Copy link
Member
tiran commented Jul 21, 2022

SGTM

We used SSL_CTX_ctrl with SSL_CTRL_GET_MAX_PROTO_VERSION because OpenSSL < 1.1.0g did not have the getter macro. Since we no longer support 1.1.0 it is safe to use the macro in 3.10 and newer.

miss-islington pushed a commit that referenced this issue Jul 21, 2022
…H-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
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jul 21, 2022
…ctrl (pythonGH-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
(cherry picked from commit 936f71e)

Co-authored-by: David Benjamin <davidben@davidben.net>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jul 21, 2022
…ctrl (pythonGH-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
(cherry picked from commit 936f71e)

Co-authored-by: David Benjamin <davidben@davidben.net>
@tiran tiran self-assigned this Jul 21, 2022
@tiran tiran added 3.11 only security fixes 3.10 only security fixes 3.12 only security fixes labels Jul 21, 2022
miss-islington added a commit that referenced this issue Jul 21, 2022
…H-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
(cherry picked from commit 936f71e)

Co-authored-by: David Benjamin <davidben@davidben.net>
miss-islington added a commit that referenced this issue Jul 21, 2022
…H-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
(cherry picked from commit 936f71e)

Co-authored-by: David Benjamin <davidben@davidben.net>
@tiran
Copy link
Member
tiran commented Jul 21, 2022

Thanks David! 👍

@tiran tiran closed this as completed Jul 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.10 only security fixes 3.11 only security fixes 3.12 only security fixes type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants
0