| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4373,18 +4373,19 @@ _ssl__SSLContext_set_ecdh_curve(PySSLContext *self, PyObject *name) | |||
| 4373 | 4373 | /*[clinic end generated code: output=23022c196e40d7d2 input=c2bafb6f6e34726b]*/ | |
| 4374 | 4374 | { | |
| 4375 | 4375 | PyObject *name_bytes; | |
| 4376 | - int nid; | ||
| 4376 | + | ||
| 4377 | 4377 | if (!PyUnicode_FSConverter(name, &name_bytes)) | |
| 4378 | 4378 | return NULL; | |
| 4379 | 4379 | assert(PyBytes_Check(name_bytes)); | |
| 4380 | + #if OPENSSL_VERSION_MAJOR < 3 | ||
| 4381 | + int nid; | ||
| 4380 | 4382 | nid = OBJ_sn2nid(PyBytes_AS_STRING(name_bytes)); | |
| 4381 | 4383 | Py_DECREF(name_bytes); | |
| 4382 | 4384 | if (nid == 0) { | |
| 4383 | 4385 | PyErr_Format(PyExc_ValueError, | |
| 4384 | 4386 | "unknown elliptic curve name %R", name); | |
| 4385 | 4387 | return NULL; | |
| 4386 | 4388 | } | |
| 4387 | - #if OPENSSL_VERSION_MAJOR < 3 | ||
| 4388 | 4389 | EC_KEY *key = EC_KEY_new_by_curve_name(nid); | |
| 4389 | 4390 | if (key == NULL) { | |
| 4390 | 4391 | _setSSLError(get_state_ctx(self), NULL, 0, __FILE__, __LINE__); | |
@@ -4393,7 +4394,9 @@ _ssl__SSLContext_set_ecdh_curve(PySSLContext *self, PyObject *name) | |||
| 4393 | 4394 | SSL_CTX_set_tmp_ecdh(self->ctx, key); | |
| 4394 | 4395 | EC_KEY_free(key); | |
| 4395 | 4396 | #else | |
| 4396 | - if (!SSL_CTX_set1_groups(self->ctx, &nid, 1)) { | ||
| 4397 | + int res = SSL_CTX_set1_groups_list(self->ctx, PyBytes_AS_STRING(name_bytes)); | ||
| 4398 | + Py_DECREF(name_bytes); | ||
| 4399 | + if (!res) { | ||
| 4397 | 4400 | _setSSLError(get_state_ctx(self), NULL, 0, __FILE__, __LINE__); | |
| 4398 | 4401 | return NULL; | |
| 4399 | 4402 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments