@@ -255,28 +255,45 @@ static int set_dh_params_db(WOLFSSL_CTX * ctx, str *blob)
255
255
return 0 ;
256
256
}
257
257
258
- static int set_ec_params (WOLFSSL_CTX * ctx , const char * curve_name )
258
+ static int set_ec_params (WOLFSSL_CTX * ctx , enum tls_method method ,
259
+ int is_server , char * curve_name )
259
260
{
260
261
int curve = 0 ;
261
- if (curve_name ) {
262
- curve = wolfSSL_OBJ_txt2nid (curve_name );
263
- }
264
- if (curve > 0 ) {
265
- WOLFSSL_EC_KEY * ecdh = wolfSSL_EC_KEY_new_by_curve_name (curve );
266
- if (! ecdh ) {
267
- LM_ERR ("unable to create EC curve\n" );
262
+
263
+ if (is_server ) {
264
+ if (curve_name )
265
+ curve = wolfSSL_OBJ_txt2nid (curve_name );
266
+ if (curve > 0 ) {
267
+ WOLFSSL_EC_KEY * ecdh = wolfSSL_EC_KEY_new_by_curve_name (curve );
268
+ if (!ecdh ) {
269
+ LM_ERR ("unable to create EC curve\n" );
270
+ return -1 ;
271
+ }
272
+ if (1 != wolfSSL_SSL_CTX_set_tmp_ecdh (ctx , ecdh )) {
273
+ LM_ERR ("unable to set tmp_ecdh\n" );
274
+ return -1 ;
275
+ }
276
+ wolfSSL_EC_KEY_free (ecdh );
277
+ } else {
278
+ LM_ERR ("unable to find the EC curve\n" );
268
279
return -1 ;
269
280
}
270
- if (1 != wolfSSL_SSL_CTX_set_tmp_ecdh (ctx , ecdh )) {
271
- LM_ERR ("unable to set tmp_ecdh\n" );
272
- return -1 ;
281
+ } else {
282
+ if (method == TLS_USE_TLSv1_3 ) {
283
+ if (wolfSSL_CTX_set1_groups_list (ctx , curve_name ) ==
284
+ WOLFSSL_FAILURE ) {
285
+ LM_ERR ("Failed to set EC curve\n" );
286
+ return -1 ;
287
+ }
288
+ } else {
289
+ if (wolfSSL_CTX_set1_curves_list (ctx , curve_name ) ==
290
+ WOLFSSL_FAILURE ) {
291
+ LM_ERR ("Failed to set EC curve\n" );
292
+ return -1 ;
293
+ }
273
294
}
274
- wolfSSL_EC_KEY_free (ecdh );
275
- }
276
- else {
277
- LM_ERR ("unable to find the EC curve\n" );
278
- return -1 ;
279
295
}
296
+
280
297
return 0 ;
281
298
}
282
299
@@ -503,7 +520,8 @@ int _wolfssl_init_tls_dom(struct tls_domain *d, int init_flags)
503
520
504
521
if (!d -> tls_ec_curve )
505
522
LM_NOTICE ("No EC curve defined\n" );
506
- else if (set_ec_params (d -> ctx , d -> tls_ec_curve ) < 0 )
523
+ else if (set_ec_params (d -> ctx , d -> method , d -> flags & DOM_FLAG_SRV ,
524
+ d -> tls_ec_curve ) < 0 )
507
525
goto end ;
508
526
509
527
if (d -> ciphers_list != 0 &&
0 commit comments