Skip to content

feature: add ssl trusted certificate #2329

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

theweakgod
Copy link
Contributor

This mainly adds the ssl_trusted_certificate feature to avoid issues where CA authentication issued by secondary certificates cannot succeed in mTLS. Added the trusted_cert parameter option for verify_client.
I have made the corresponding modifications at the lua-resty-core:
openresty/lua-resty-core#473

@theweakgod theweakgod changed the title Feature/add ssl trusted certificate feature: add ssl trusted certificate Jul 4, 2024
@zhuizhuhaomeng
Copy link
Contributor

Will you show us a detailed example of the mTLS failed

@theweakgod
Copy link
Contributor Author

Will you show us a detailed example of the mTLS failed

The scenario is as follows: verify_client will send the subject names of all CA. However, we do not want to expose the root subject name, so verify_client only wants to send the subject names of the intermediate CA to the client. So we only set intermediate CA in verify_client, but this will cause the verification to fail because the root CA is not trusted.

We have tried configuring nginx ssl_trusted_certificate and simultaneously calling verify_client to send the intermediate CA, but found it doesn't work. After reading the source code, I discovered that verify_client overrides the cert->verify_store configured in nginx, and this operation is implicit in verify_client. So, I created this pull request.

This scenario can be resolved by configuring nginx as follows:

ssl_client_certificate client-server.crt;
ssl_trusted_certificate client-server-root.crt;
ssl_verify_depth 2;
ssl_verify_client on;

More details can be found in Test 13(140-ssl-c-api.t).

@@ -1468,8 +1468,8 @@ ngx_http_lua_ssl_verify_callback(int ok, X509_STORE_CTX *x509_store)


int
ngx_http_lua_ffi_ssl_verify_client(ngx_http_request_t *r, void *ca_certs,
int depth, char **err)
ngx_http_lua_ffi_ssl_verify_client(ngx_http_request_t *r, void *ca_certs,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove the trailing space

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

*err = "X509_STORE_add_cert() failed";
goto failed;
if (trusted_chain != NULL) {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the extra blank line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@zhuizhuhaomeng zhuizhuhaomeng merged commit 45c63cd into openresty:master Jul 9, 2024
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants