summaryrefslogtreecommitdiffstats
path: root/Modules/_ssl.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/_ssl.c')
-rw-r--r--Modules/_ssl.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/Modules/_ssl.c b/Modules/_ssl.c
index 5f17cd5..c9e2f24 100644
--- a/Modules/_ssl.c
+++ b/Modules/_ssl.c
@@ -4336,8 +4336,6 @@ _ssl__SSLContext_set_ecdh_curve(PySSLContext *self, PyObject *name)
{
PyObject *name_bytes;
int nid;
- EC_KEY *key;
-
if (!PyUnicode_FSConverter(name, &name_bytes))
return NULL;
assert(PyBytes_Check(name_bytes));
@@ -4348,13 +4346,20 @@ _ssl__SSLContext_set_ecdh_curve(PySSLContext *self, PyObject *name)
"unknown elliptic curve name %R", name);
return NULL;
}
- key = EC_KEY_new_by_curve_name(nid);
+#if OPENSSL_VERSION_MAJOR < 3
+ EC_KEY *key = EC_KEY_new_by_curve_name(nid);
if (key == NULL) {
_setSSLError(get_state_ctx(self), NULL, 0, __FILE__, __LINE__);
return NULL;
}
SSL_CTX_set_tmp_ecdh(self->ctx, key);
EC_KEY_free(key);
+#else
+ if (!SSL_CTX_set1_groups(self->ctx, &nid, 1)) {
+ _setSSLError(get_state_ctx(self), NULL, 0, __FILE__, __LINE__);
+ return NULL;
+ }
+#endif
Py_RETURN_NONE;
}