Skip to content

Commit

Permalink
[tls_validation] Return early if no client certificate is presented
Browse files Browse the repository at this point in the history
  • Loading branch information
tkan145 committed Aug 26, 2024
1 parent 8f0973d commit 8f93e40
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions gateway/src/apicast/policy/tls_validation/tls_validation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ end

function _M:access()
local cert = X509.parse_pem_cert(ngx.var.ssl_client_raw_cert)
if not cert then
ngx.status = self.error_status
ngx.say("No required SSL certificate was sent")
return ngx.exit(ngx.status)
end
local store = self.x509_store

local ok, err = store:validate_cert(cert)
Expand Down
2 changes: 1 addition & 1 deletion t/apicast-policy-tls_validation.t
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ proxy_pass https://$server_addr:$apicast_port/t;
proxy_set_header Host test;
log_by_lua_block { collectgarbage() }
--- response_body
Invalid certificate verification context
No required SSL certificate was sent
--- error_code: 400
--- no_error_log
[error]
Expand Down

0 comments on commit 8f93e40

Please sign in to comment.