Skip to content

Commit 0303d9f

Browse files
nvbolhuislws-team
authored andcommitted
LWS_SERVER_OPTION_OPENSSL_AUTO_DH_PARAMETERS takes care of providing a
DH group, aka. finite field group, aka. "DH parameters" (by calling SSL_CTX_set_dh_auto) in case TLSv1.2 Kx=DH ciphers (e.g. TLS_DHE_RSA_WITH_AES_256_GCM_SHA384) are selected. Signed-off-by: Norbert van Bolhuis <nvbolhuis@gmail.com>
1 parent 94259fb commit 0303d9f

3 files changed

Lines changed: 15 additions & 0 deletions

File tree

include/libwebsockets/lws-context-vhost.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,12 @@
242242
#define LWS_SERVER_OPTION_DISABLE_TLS_SESSION_CACHE (1ll << 39)
243243
/**< (VHOST) Disallow use of client tls caching (on by default) */
244244

245+
#define LWS_SERVER_OPTION_OPENSSL_AUTO_DH_PARAMETERS (1ll << 40)
246+
/**< Configure openssl to use the default built-in DH parameters
247+
* to support TLSv1.2 Kx=DH ciphers (by calling SSL_CTX_set_dh_auto)
248+
* This is needed when you want to enable TLSv1.2 ephemeral
249+
* Diffie-Hellman (DH) key exchange ciphers
250+
* (e.g. TLS_DHE_RSA_WITH_AES_256_GCM_SHA384). It's not recommended. */
245251

246252
/****** add new things just above ---^ ******/
247253

lib/tls/openssl/openssl-server.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,10 @@ lws_tls_server_vhost_backend_init(const struct lws_context_creation_info *info,
520520
#ifdef SSL_OP_NO_COMPRESSION
521521
SSL_CTX_set_options(vhost->tls.ssl_ctx, SSL_OP_NO_COMPRESSION);
522522
#endif
523+
if (lws_check_opt(info->options,
524+
LWS_SERVER_OPTION_OPENSSL_AUTO_DH_PARAMETERS))
525+
SSL_CTX_set_dh_auto(vhost->tls.ssl_ctx, 1);
526+
523527
SSL_CTX_set_options(vhost->tls.ssl_ctx, SSL_OP_SINGLE_DH_USE);
524528
SSL_CTX_set_options(vhost->tls.ssl_ctx, SSL_OP_CIPHER_SERVER_PREFERENCE);
525529

test-apps/test-server.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,11 @@ int main(int argc, char **argv)
579579
"!DHE-RSA-AES256-SHA256:"
580580
"!AES256-GCM-SHA384:"
581581
"!AES256-SHA256";
582+
/*
583+
* This is needed for DHE-RSA-AES256-GCM-SHA384, it does enable all
584+
* TLSv1.2 Kx=DH ciphers though (if the're on the ssl_cipher_list).
585+
*/
586+
info.options |= LWS_SERVER_OPTION_OPENSSL_AUTO_DH_PARAMETERS;
582587
#endif
583588
info.mounts = &mount;
584589
#if defined(LWS_WITH_PEER_LIMITS)

0 commit comments

Comments
 (0)