File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 249249 * Diffie-Hellman (DH) key exchange ciphers
250250 * (e.g. TLS_DHE_RSA_WITH_AES_256_GCM_SHA384). It's not recommended. */
251251
252+ #define LWS_SERVER_OPTION_MBEDTLS_VERIFY_CLIENT_CERT_POST_HANDSHAKE ((1ll << 41) | \
253+ (1ll << 12))
254+ /**< (VH) An option to be used with mbedtls only, forces server to load
255+ * and store the client cert (without CA dependent check)
256+ * to be able to verify it later (after the handshake);
257+ * provides LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT.
258+ * Note: LWS_SERVER_OPTION_REQUIRE_VALID_OPENSSL_CLIENT_CERT and
259+ * LWS_SERVER_OPTION_PEER_CERT_NOT_REQUIRED are ignored if
260+ * LWS_SERVER_OPTION_MBEDTLS_VERIFY_CLIENT_CERT_POST_HANDSHAKE is set */
261+
252262 /****** add new things just above ---^ ******/
253263
254264
Original file line number Diff line number Diff line change @@ -31,6 +31,15 @@ lws_tls_server_client_cert_verify_config(struct lws_vhost *vh)
3131{
3232 int verify_options = SSL_VERIFY_PEER ;
3333
34+ if (lws_check_opt (vh -> options ,
35+ LWS_SERVER_OPTION_MBEDTLS_VERIFY_CLIENT_CERT_POST_HANDSHAKE )) {
36+ verify_options |= SSL_VERIFY_POST_HANDSHAKE ;
37+ SSL_CTX_set_verify (vh -> tls .ssl_ctx , verify_options , NULL );
38+ lwsl_notice ("%s: vh %s can verify client cert post-handshake\n" ,
39+ __func__ , vh -> name );
40+ return 0 ;
41+ }
42+
3443 /* as a server, are we requiring clients to identify themselves? */
3544 if (!lws_check_opt (vh -> options ,
3645 LWS_SERVER_OPTION_REQUIRE_VALID_OPENSSL_CLIENT_CERT )) {
Original file line number Diff line number Diff line change 3131# define SSL_VERIFY_PEER 0x01
3232# define SSL_VERIFY_FAIL_IF_NO_PEER_CERT 0x02
3333# define SSL_VERIFY_CLIENT_ONCE 0x04
34+ # define SSL_VERIFY_POST_HANDSHAKE 0x08
3435
3536/*
3637 * The following 3 states are kept in ssl->rlayer.rstate when reads fail, you
Original file line number Diff line number Diff line change @@ -257,7 +257,9 @@ static int ssl_pm_reload_crt(SSL *ssl)
257257 struct pkey_pm * pkey_pm = (struct pkey_pm * )ssl -> cert -> pkey -> pkey_pm ;
258258 struct x509_pm * crt_pm = (struct x509_pm * )ssl -> cert -> x509 -> x509_pm ;
259259
260- if ((ssl -> verify_mode & SSL_VERIFY_PEER ) > 0 )
260+ if ((ssl -> verify_mode & SSL_VERIFY_POST_HANDSHAKE ) > 0 )
261+ mode = MBEDTLS_SSL_VERIFY_OPTIONAL ;
262+ else if ((ssl -> verify_mode & SSL_VERIFY_PEER ) > 0 )
261263 mode = MBEDTLS_SSL_VERIFY_REQUIRED ;
262264 else if ((ssl -> verify_mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT ) > 0 )
263265 mode = MBEDTLS_SSL_VERIFY_OPTIONAL ;
You can’t perform that action at this time.
0 commit comments