Opened 2 weeks ago

Closed 11 days ago

#2008 closed defect (fixed)

699f6e55bbb4 causes request for client certificate

Reported by: hreinnbeck@… Owned by: Maxim Dounin
Priority: minor Milestone:
Component: documentation Version: 1.19.x
Keywords: Cc:
uname -a: Linux dev-staging 5.4.0-37-generic #41-Ubuntu SMP Wed Jun 3 18:57:02 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
nginx -V: nginx version: nginx/1.19.1
built by gcc 9.3.0 (Ubuntu 9.3.0-10ubuntu2)
built with OpenSSL 1.1.1g 21 Apr 2020
TLS SNI support enabled
configure arguments: --sbin-path=/usr/sbin --prefix=/etc/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --with-pcre --with-pcre-jit --with-stream --with-stream_ssl_module --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_realip_module --with-http_secure_link_module --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-http_v2_module --with-http_slice_module --with-file-aio --with-threads --with-http_v2_module --with-cc-opt='-O3 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=native -DTCP_FASTOPEN=23 -Wno-deprecated-declarations -march=native -Wno-error=free-nonheap-object -Wno-implicit-fallthrough' --with-ld-opt='-Wl,-z,relro -Wl,-E' --add-module=/usr/src/nginx_modules/ngx_brotli --add-module=/usr/src/nginx_modules/nginx-akamai-token-validate-module --add-module=/usr/src/nginx_modules/nginx-secure-token-module --add-module=/usr/src/nginx_modules/headers-more-nginx-module --add-module=/usr/src/nginx_modules/nchan --add-module=/usr/src/nginx_modules/nginx-vod-module --add-module=/usr/src/nginx_modules/echo-nginx-module --add-module=/usr/src/nginx_modules/ngx_http_substitutions_filter_module --add-module=/usr/src/nginx_modules/redis2-nginx-module

Latest commit: ccb5ff87ab3e

Description (last modified by hreinnbeck@…)

A few users (using Chrome and Safari) where getting request for client certificates upon connecting to the site. I was unable to reproduce the error until I installed another client certificate in Chrome (so it prompts to select certificate).

I double checked the config and none of the options for client certificates were set. I also added "ssl_verify_client off;" just to be sure.

After reverting 699f6e55bbb4 the users are no longer getting client certificate requests.

Change History (4)

comment:1 by hreinnbeck@…, 2 weeks ago

Description: modified (diff)

comment:2 by Maxim Dounin, 2 weeks ago

Owner: set to Maxim Dounin
Status: newassigned

Thanks for reporting this, indeed looks like a bug introduced in 699f6e55bbb4. The following patch should fix this:

# HG changeset patch
# User Maxim Dounin <mdounin@mdounin.ru>
# Date 1593209659 -10800
#      Sat Jun 27 01:14:19 2020 +0300
# Node ID cf3cb200ef0e166f28bd88d47234a7b9b791c97a
# Parent  7e0719fb528b0ed33ef2670b9b79a6f52744f053
SSL: fixed unexpected certificate requests (ticket #2008).

Using SSL_CTX_set_verify(SSL_VERIFY_PEER) implies that OpenSSL will
sent a certificate request during an SSL handshake, leading to unexpected
certificate requests from browsers as long as there are any client
certificates installed.  Given that ngx_ssl_trusted_certificate()
is called unconditionally by the ngx_http_ssl_module, this affected all
SSL-enabled servers.  Broken by 699f6e55bbb4 (not released yet).

Fix is to set verify callback in the ngx_ssl_trusted_certificate() function
without changing the verify mode.

diff --git a/src/event/ngx_event_openssl.c b/src/event/ngx_event_openssl.c
--- a/src/event/ngx_event_openssl.c
+++ b/src/event/ngx_event_openssl.c
@@ -920,7 +920,8 @@ ngx_int_t
 ngx_ssl_trusted_certificate(ngx_conf_t *cf, ngx_ssl_t *ssl, ngx_str_t *cert,
     ngx_int_t depth)
 {
-    SSL_CTX_set_verify(ssl->ctx, SSL_VERIFY_PEER, ngx_ssl_verify_callback);
+    SSL_CTX_set_verify(ssl->ctx, SSL_CTX_get_verify_mode(ssl->ctx),
+                       ngx_ssl_verify_callback);
 
     SSL_CTX_set_verify_depth(ssl->ctx, depth);
 

comment:3 by Maxim Dounin <mdounin@…>, 11 days ago

In 7672:3dcb1aba894a/nginx:

SSL: fixed unexpected certificate requests (ticket #2008).

Using SSL_CTX_set_verify(SSL_VERIFY_PEER) implies that OpenSSL will
send a certificate request during an SSL handshake, leading to unexpected
certificate requests from browsers as long as there are any client
certificates installed. Given that ngx_ssl_trusted_certificate()
is called unconditionally by the ngx_http_ssl_module, this affected
all HTTPS servers. Broken by 699f6e55bbb4 (not released yet).

Fix is to set verify callback in the ngx_ssl_trusted_certificate() function
without changing the verify mode.

comment:4 by Maxim Dounin, 11 days ago

Resolution: fixed
Status: assignedclosed

Should be fixed now, thanks.

Note: See TracTickets for help on using tickets.