wolfSSL_X509_verify_cert: add host check from ctx->param#9952
wolfSSL_X509_verify_cert: add host check from ctx->param#9952julek-wolfssl wants to merge 6 commits intowolfSSL:masterfrom
ctx->param#9952Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds OpenSSL-compatible hostname/IP enforcement to wolfSSL_X509_verify_cert() based on values set in WOLFSSL_X509_STORE_CTX->param, and introduces a regression test to ensure hostname mismatches are rejected.
Changes:
- Enforce hostname (
hostName) and IP (ipasc) checks duringwolfSSL_X509_verify_cert()when configured viaX509_VERIFY_PARAM. - Add a regression test that verifies hostname match/mismatch behavior and the resulting error code.
- Register the new test in the API test declarations.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/x509_str.c |
Adds hostname/IP enforcement to wolfSSL_X509_verify_cert() when ctx->param is configured. |
tests/api/test_x509.c |
Adds a regression test covering success with no hostname, success with matching SAN DNS, and failure on mismatch. |
tests/api/test_x509.h |
Exposes and registers the new test in the x509 test group. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
- Use WOLFSSL_-prefixed error constants (always available) instead of OPENSSL_COEXIST-guarded macros, fixing error code mismatch in coexist builds - Set ctx->current_cert = orig on hostname/IP mismatch so error reporting aligns with error_depth = 0 (leaf cert) - Add IP address verification test cases (match + mismatch)
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
tests/api.c:1
- These newly added error-code table entries don’t line up with the new verify error values introduced in
wolfssl/ssl.h(HOSTNAME_MISMATCH = 62,IP_ADDRESS_MISMATCH = 64). As written, this looks like an off-by-one / wrong-code mapping (and61 -> 30is especially suspicious given the new enums). Please update this table to use the correct reason codes and expected mapped values (e.g., ensure 62 and 64 are covered, and only include 63 if the corresponding enum/string/mapping also exists).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| if (ret == WOLFSSL_SUCCESS && ctx->param != NULL) { | ||
| if (ctx->param->hostName[0] != '\0') { | ||
| if (wolfSSL_X509_check_host(orig, | ||
| ctx->param->hostName, | ||
| XSTRLEN(ctx->param->hostName), | ||
| ctx->param->hostFlags, NULL) != WOLFSSL_SUCCESS) { | ||
| ctx->error = WOLFSSL_X509_V_ERR_HOSTNAME_MISMATCH; | ||
| ctx->error_depth = 0; | ||
| ctx->current_cert = orig; | ||
| ret = WOLFSSL_FAILURE; | ||
| } | ||
| } | ||
| else if (ctx->param->ipasc[0] != '\0') { | ||
| if (wolfSSL_X509_check_ip_asc(orig, | ||
| ctx->param->ipasc, | ||
| ctx->param->hostFlags) != WOLFSSL_SUCCESS) { | ||
| ctx->error = WOLFSSL_X509_V_ERR_IP_ADDRESS_MISMATCH; | ||
| ctx->error_depth = 0; | ||
| ctx->current_cert = orig; | ||
| ret = WOLFSSL_FAILURE; | ||
| } | ||
| } | ||
| } |
ZD21324