@@ -4373,18 +4373,19 @@ _ssl__SSLContext_set_ecdh_curve(PySSLContext *self, PyObject *name)
43734373/*[clinic end generated code: output=23022c196e40d7d2 input=c2bafb6f6e34726b]*/
43744374{
43754375PyObject * name_bytes ;
4376- int nid ;
4376+
43774377if (!PyUnicode_FSConverter (name ,& name_bytes ))
43784378return NULL ;
43794379assert (PyBytes_Check (name_bytes ));
4380+ #if OPENSSL_VERSION_MAJOR < 3
4381+ int nid ;
43804382nid = OBJ_sn2nid (PyBytes_AS_STRING (name_bytes ));
43814383Py_DECREF (name_bytes );
43824384if (nid == 0 ) {
43834385PyErr_Format (PyExc_ValueError ,
43844386"unknown elliptic curve name %R" ,name );
43854387return NULL ;
43864388 }
4387- #if OPENSSL_VERSION_MAJOR < 3
43884389EC_KEY * key = EC_KEY_new_by_curve_name (nid );
43894390if (key == NULL ) {
43904391_setSSLError (get_state_ctx (self ),NULL ,0 ,__FILE__ ,__LINE__ );
@@ -4393,7 +4394,9 @@ _ssl__SSLContext_set_ecdh_curve(PySSLContext *self, PyObject *name)
43934394SSL_CTX_set_tmp_ecdh (self -> ctx ,key );
43944395EC_KEY_free (key );
43954396#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 ) {
43974400_setSSLError (get_state_ctx (self ),NULL ,0 ,__FILE__ ,__LINE__ );
43984401return NULL ;
43994402 }