-
-
Notifications
You must be signed in to change notification settings - Fork 34.3k
gh-146207: Add support for OpenSSL 4.0.0 alpha1 #146217
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
base: main
Are you sure you want to change the base?
Changes from all commits
9359f01
5f9bc31
8e607c4
a5152be
4ee447a
71e9c1a
4b55d22
1b64620
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Add support for OpenSSL 4.0.0 alpha1. Patch by Victor Stinner. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -164,6 +164,17 @@ static void _PySSLFixErrno(void) { | |
| #error Unsupported OpenSSL version | ||
| #endif | ||
|
|
||
| #if (OPENSSL_VERSION_NUMBER >= 0x40000000L) | ||
| # define OPENSSL_NO_SSL3 | ||
vstinner marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # define OPENSSL_NO_TLS1 | ||
| # define OPENSSL_NO_TLS1_1 | ||
| # define OPENSSL_NO_TLS1_2 | ||
| # define OPENSSL_NO_SSL3_METHOD | ||
| # define OPENSSL_NO_TLS1_METHOD | ||
| # define OPENSSL_NO_TLS1_1_METHOD | ||
| # define OPENSSL_NO_TLS1_2_METHOD | ||
| #endif | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I cannot comment on the lines above this block but we need to check if mnemonics changed in 4.0 as well and generate dedicated data. I would still generate dedicated data just because the major version was bumped.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I expect that OpenSSL will still change before the OpenSSL 4.0 final release. Can we wait for the final release before generating the "ssl data" header file?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes we can. |
||
|
|
||
| /* OpenSSL API 1.1.0+ does not include version methods */ | ||
| #ifndef OPENSSL_NO_SSL3_METHOD | ||
| extern const SSL_METHOD *SSLv3_method(void); | ||
|
|
@@ -1151,7 +1162,7 @@ _asn1obj2py(_sslmodulestate *state, const ASN1_OBJECT *name, int no_name) | |
|
|
||
| static PyObject * | ||
| _create_tuple_for_attribute(_sslmodulestate *state, | ||
| ASN1_OBJECT *name, ASN1_STRING *value) | ||
| const ASN1_OBJECT *name, const ASN1_STRING *value) | ||
| { | ||
| Py_ssize_t buflen; | ||
| PyObject *pyattr; | ||
|
|
@@ -1180,16 +1191,16 @@ _create_tuple_for_attribute(_sslmodulestate *state, | |
| } | ||
|
|
||
| static PyObject * | ||
| _create_tuple_for_X509_NAME (_sslmodulestate *state, X509_NAME *xname) | ||
| _create_tuple_for_X509_NAME(_sslmodulestate *state, const X509_NAME *xname) | ||
| { | ||
| PyObject *dn = NULL; /* tuple which represents the "distinguished name" */ | ||
| PyObject *rdn = NULL; /* tuple to hold a "relative distinguished name" */ | ||
| PyObject *rdnt; | ||
| PyObject *attr = NULL; /* tuple to hold an attribute */ | ||
| int entry_count = X509_NAME_entry_count(xname); | ||
| X509_NAME_ENTRY *entry; | ||
| ASN1_OBJECT *name; | ||
| ASN1_STRING *value; | ||
| const X509_NAME_ENTRY *entry; | ||
| const ASN1_OBJECT *name; | ||
| const ASN1_STRING *value; | ||
| int index_counter; | ||
| int rdn_level = -1; | ||
| int retcode; | ||
|
|
@@ -6967,9 +6978,15 @@ sslmodule_init_constants(PyObject *m) | |
| ADD_INT_CONST("PROTOCOL_TLS", PY_SSL_VERSION_TLS); | ||
| ADD_INT_CONST("PROTOCOL_TLS_CLIENT", PY_SSL_VERSION_TLS_CLIENT); | ||
| ADD_INT_CONST("PROTOCOL_TLS_SERVER", PY_SSL_VERSION_TLS_SERVER); | ||
| #ifndef OPENSSL_NO_TLS1 | ||
| ADD_INT_CONST("PROTOCOL_TLSv1", PY_SSL_VERSION_TLS1); | ||
| #endif | ||
| #ifndef OPENSSL_NO_TLS1_1 | ||
| ADD_INT_CONST("PROTOCOL_TLSv1_1", PY_SSL_VERSION_TLS1_1); | ||
| #endif | ||
| #ifndef OPENSSL_NO_TLS1_2 | ||
| ADD_INT_CONST("PROTOCOL_TLSv1_2", PY_SSL_VERSION_TLS1_2); | ||
| #endif | ||
|
|
||
| #define ADD_OPTION(NAME, VALUE) if (sslmodule_add_option(m, NAME, (VALUE)) < 0) return -1 | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -427,11 +427,11 @@ class BuildOpenSSL(AbstractBuilder): | |
| depend_target = 'depend' | ||
|
|
||
| def _post_install(self): | ||
| if self.version.startswith("3."): | ||
| if self.version.startswith(("3.", "4.")): | ||
| self._post_install_3xx() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the future, it is better to have two methods for post install, one for 3.x and one for 4.x
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently, the script does the same operations on OpenSSL 3 and OpenSSL 4. Is it worth it to have two methods which do the same operations?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would say yes as we do not know what will be needed with 4.x (I do not mind having the 4xx call the 3xx with a comment saying that for now it is identical). I will give you an answer about it once I looked at the OpenSSL roadmap so ok for leaving it that way for now. |
||
|
|
||
| def _build_src(self, config_args=()): | ||
| if self.version.startswith("3."): | ||
| if self.version.startswith(("3.", "4.")): | ||
| config_args += ("enable-fips",) | ||
| super()._build_src(config_args) | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it possible to retain those constants using the OpenSSL compatibility features or are these constants entirely gone?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 4 methods are gone but I cannot find
OPENSSL_NO_macro in the public header files:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that I think more about it, I think those macros are defined by your build configuration and the generated headers. I never remember which macro is defined explicitly through other macros and which macros are defined dynamically after the configure step