Skip to content

Commit c866e23

Browse files
committed
Enable TLS certificate verification for OIDC IdP upstream connections.
Updates `openid_connect.server_conf` to enforce secure TLS settings on all IdP-bound requests (`/_token`, `/_refresh`, `/_jwks_uri`). This adds: - `proxy_ssl_verify on` to enforce verification of the OP’s TLS certificate. - `proxy_ssl_trusted_certificate /etc/ssl/certs/ca-certificates.crt` to use the system (Debian/Ubuntu/Alpine) CA bundle for trust. - `proxy_ssl_verify_depth 2` to allow certificate chains up to one intermediate CA.
1 parent 24d53f9 commit c866e23

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ Manual configuration involves reviewing the following files so that they match y
190190
* No changes are usually required here
191191
* Modify the `resolver` directive to match a DNS server that is capable of resolving the IdP defined in `$oidc_token_endpoint` and `$oidc_end_session_endpoint`
192192
* If using [`auth_jwt_key_request`](http://nginx.org/en/docs/http/ngx_http_auth_jwt_module.html#auth_jwt_key_request) to automatically fetch the JWK file from the IdP then modify the validity period and other caching options to suit your IdP
193+
* TLS certificate verification for all IdP-bound requests (token, refresh, JWKS) is enabled by default. NGINX Plus uses the system CA bundle at `/etc/ssl/certs/ca-certificates.crt` (via [`proxy_ssl_trusted_certificate`](http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_ssl_trusted_certificate)) to validate the IdP’s TLS certificate. If the IdP’s certificate is signed by a private or custom CA, append that CA to this bundle or update the `proxy_ssl_trusted_certificate` path accordingly.
194+
* The [`proxy_ssl_verify_depth`](http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_ssl_verify_depth) directive is set to **2** by default, allowing one intermediate CA in the chain. This is sufficient for most public IdPs.
193195

194196
* **openid_connect.js** - this is the JavaScript code for performing the authorization code exchange and nonce hashing
195197
* No changes are required unless modifying the code exchange or validation process
@@ -320,3 +322,4 @@ This reference implementation for OpenID Connect is supported for NGINX Plus sub
320322
* **R28** Access token support. Added support for access token to authorize NGINX to access protected backend.
321323
* **R32** Added support for `client_secret_basic` client authentication method.
322324
* **R33** Refactor code to use async/await. Implement Front-Channel Logout endpoint.
325+
* **R36** Enable TLS certificate verification for all IdP-bound requests by default.

openid_connect.server_conf

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@
1313
proxy_cache jwk; # Cache the JWK Set received from IdP
1414
proxy_cache_valid 200 12h; # How long to consider keys "fresh"
1515
proxy_cache_use_stale error timeout updating; # Use old JWK Set if cannot reach IdP
16-
proxy_ssl_server_name on; # For SNI to the IdP
16+
17+
proxy_ssl_verify on; # Enforce TLS certificate verification
18+
proxy_ssl_verify_depth 2; # Allow intermediate CA chains of depth 2
19+
proxy_ssl_server_name on; # Send SNI to IdP host
20+
proxy_ssl_trusted_certificate /etc/ssl/certs/ca-certificates.crt; # Use system CA bundle
21+
1722
proxy_method GET; # In case client request was non-GET
1823
proxy_set_header Content-Length ""; # ''
1924
proxy_pass $oidc_jwt_keyfile; # Expecting to find a URI here
@@ -43,7 +48,11 @@
4348
# Exclude client headers to avoid CORS errors with certain IdPs (e.g., Microsoft Entra ID)
4449
proxy_pass_request_headers off;
4550

46-
proxy_ssl_server_name on; # For SNI to the IdP
51+
proxy_ssl_verify on; # Enforce TLS certificate verification
52+
proxy_ssl_verify_depth 2; # Allow intermediate CA chains of depth 2
53+
proxy_ssl_server_name on; # Send SNI to IdP host
54+
proxy_ssl_trusted_certificate /etc/ssl/certs/ca-certificates.crt; # Use system CA bundle
55+
4756
proxy_set_header Content-Type "application/x-www-form-urlencoded";
4857
proxy_set_header Authorization $arg_secret_basic;
4958
proxy_pass $oidc_token_endpoint;
@@ -58,7 +67,11 @@
5867
# Exclude client headers to avoid CORS errors with certain IdPs (e.g., Microsoft Entra ID)
5968
proxy_pass_request_headers off;
6069

61-
proxy_ssl_server_name on; # For SNI to the IdP
70+
proxy_ssl_verify on; # Enforce TLS certificate verification
71+
proxy_ssl_verify_depth 2; # Allow intermediate CA chains of depth 2
72+
proxy_ssl_server_name on; # Send SNI to IdP host
73+
proxy_ssl_trusted_certificate /etc/ssl/certs/ca-certificates.crt; # Use system CA bundle
74+
6275
proxy_set_header Content-Type "application/x-www-form-urlencoded";
6376
proxy_set_header Authorization $arg_secret_basic;
6477
proxy_pass $oidc_token_endpoint;

0 commit comments

Comments
 (0)