| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,2 @@ | |||
| 1 | + Migrate :meth:`~ssl.SSLContext.set_ecdh_curve` method not to use deprecated | ||
| 2 | + OpenSSL APIs. Patch by Dong-hee Na. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4355,8 +4355,6 @@ _ssl__SSLContext_set_ecdh_curve(PySSLContext *self, PyObject *name) | |||
| 4355 | 4355 | { | |
| 4356 | 4356 | PyObject *name_bytes; | |
| 4357 | 4357 | int nid; | |
| 4358 | - EC_KEY *key; | ||
| 4359 | - | ||
| 4360 | 4358 | if (!PyUnicode_FSConverter(name, &name_bytes)) | |
| 4361 | 4359 | return NULL; | |
| 4362 | 4360 | assert(PyBytes_Check(name_bytes)); | |
@@ -4367,13 +4365,20 @@ _ssl__SSLContext_set_ecdh_curve(PySSLContext *self, PyObject *name) | |||
| 4367 | 4365 | "unknown elliptic curve name %R", name); | |
| 4368 | 4366 | return NULL; | |
| 4369 | 4367 | } | |
| 4370 | - key = EC_KEY_new_by_curve_name(nid); | ||
| 4368 | + #if OPENSSL_VERSION_MAJOR < 3 | ||
| 4369 | + EC_KEY *key = EC_KEY_new_by_curve_name(nid); | ||
| 4371 | 4370 | if (key == NULL) { | |
| 4372 | 4371 | _setSSLError(get_state_ctx(self), NULL, 0, __FILE__, __LINE__); | |
| 4373 | 4372 | return NULL; | |
| 4374 | 4373 | } | |
| 4375 | 4374 | SSL_CTX_set_tmp_ecdh(self->ctx, key); | |
| 4376 | 4375 | EC_KEY_free(key); | |
| 4376 | + #else | ||
| 4377 | + if (!SSL_CTX_set1_groups(self->ctx, &nid, 1)) { | ||
| 4378 | + _setSSLError(get_state_ctx(self), NULL, 0, __FILE__, __LINE__); | ||
| 4379 | + return NULL; | ||
| 4380 | + } | ||
| 4381 | + #endif | ||
| 4377 | 4382 | Py_RETURN_NONE; | |
| 4378 | 4383 | } | |
| 4379 | 4384 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments