Use wolfSSL's EmbedOcspLookup in non-blocking async OCSP example - #604
Use wolfSSL's EmbedOcspLookup in non-blocking async OCSP example#604night1rider wants to merge 2 commits into
Conversation
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #604
Scan targets checked: wolfssl-examples-bugs, wolfssl-examples-src
Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Findings are non-blocking.
c7c49f3 to
8d7c242
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #604
Scan targets checked: wolfssl-examples-bugs, wolfssl-examples-src
Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Findings are non-blocking.
8d7c242 to
4011953
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #604
Scan targets checked: wolfssl-examples-bugs, wolfssl-examples-src
Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Findings are non-blocking.
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #604
Scan targets checked: wolfssl-examples-bugs, wolfssl-examples-src
Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Findings are non-blocking.
There was a problem hiding this comment.
Pull request overview
This PR hardens the non-blocking async OCSP example by removing execution of an untrusted OCSP responder URL via system()/curl, instead using wolfSSL’s built-in OCSP HTTP fetch API, and updates server connection setup to resolve the hostname dynamically via getaddrinfo().
Changes:
- Replace
system("curl ... <untrusted-url>")OCSP fetching withEmbedOcspLookup()+EmbedOcspRespFree(). - Resolve
SERVER_NAMEviagetaddrinfo()instead of using a hard-coded IP address. - Update README sample output to remove the printed curl command flow.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| ocsp/ocsp_nonblock/ocsp_nonblock_async.c | Switch OCSP callback to EmbedOcspLookup() and resolve server address via getaddrinfo(). |
| ocsp/ocsp_nonblock/README.md | Remove curl-command/temporary-file output lines from the example run log. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Overall this looks good and an improvement over the original system(3) based example.
Two requested changes:
- While you're updating the
README.mdwe should remove this outdated section:
NOTE: Before building this example the asynchronous support must be obtained from (https://github.com/wolfSSL/wolfAsyncCrypt) and installed into wolfSSL by following the instructions in the README file contained in the wolfAsyncCrypt repository.
The wolfAsyncCrypt repo is deprecated, and the async code is upstreamed into wolfssl now.
- It would be nice to just include a cert to use for this
ocsp_nonblock_asyncexample.
note: the google.pem used by ocsp_nonblock.c example is expired, but that's outside scope of this PR.
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #604
Scan targets checked: wolfssl-examples-bugs, wolfssl-examples-src
Fenrir result: Approved ✅
No new issues found in the changed files.
Advisory only — this automated result does not count as a GitHub approval.
8edbabb to
de2be79
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #604
Scan targets checked: wolfssl-examples-bugs, wolfssl-examples-src
Findings: 3
3 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Reported findings require changes before merge.
de2be79 to
770dfcd
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #604
Scan targets checked: wolfssl-examples-bugs, wolfssl-examples-src
Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Reported findings require changes before merge.
770dfcd to
3425718
Compare
Replace the system("curl ... <untrusted responder URL>") OCSP fetch in the async
example with wolfSSL's EmbedOcspLookup, so the certificate-supplied URL is fetched
as data over a socket instead of executed.
Both examples now target www.digicert.com (Google dropped OCSP): ocsp_nonblock
fetches the leaf live over TLS rather than a bundled cert that expires, and the
async example uses wolfSSL's native async API. Bundle the DigiCert CAs and drop
the expired google.pem and stale GTS certs.
The rewritten clients need asynccrypt/opensslextra/sni/alpn and WOLFSSL_NONBLOCK_OCSP, which the shared ocsp profile lacks; add a dedicated ocsp-nonblock profile.
3425718 to
25ff2ff
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #604
Scan targets checked: wolfssl-examples-bugs, wolfssl-examples-src
Findings: 2
2 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Reported findings require changes before merge.
| wolfSSL_set_fd(ssl, fd); | ||
| wolfSSL_UseSNI(ssl, WOLFSSL_SNI_HOST_NAME, host, (word16)XSTRLEN(host)); | ||
| /* Bind the cert to the hostname; a chain check alone is not enough. */ | ||
| wolfSSL_check_domain_name(ssl, host); |
There was a problem hiding this comment.
Return values of wolfSSL_UseSNI() and wolfSSL_check_domain_name() ignored in fetch_leaf_der() · Incorrect error handling
Every other call in fetch_leaf_der is error-checked, but wolfSSL_UseSNI and wolfSSL_check_domain_name are not. On failure the handshake proceeds with no hostname binding, silently contradicting the adjacent comment; the async example in this same PR checks both.
Related known finding #8939 (similar but distinct): Both involve failure handling being omitted, but this finding concerns ignored SNI/domain-binding return values in fetch_leaf_der, whereas #8939 concerns failure branches retaining a success return during EVP setup in encrypt_file. Their root causes and required patches differ, so one patch would not fix both.
Fix: Check both calls for WOLFSSL_SUCCESS and fail through the existing ssl/fd/ctx cleanup path on error.
| wolfSSL_set_fd(ssl, fd); | ||
| wolfSSL_UseSNI(ssl, WOLFSSL_SNI_HOST_NAME, host, (word16)XSTRLEN(host)); | ||
| /* Bind the cert to the hostname; a chain check alone is not enough. */ | ||
| wolfSSL_check_domain_name(ssl, host); |
There was a problem hiding this comment.
Peer identity binding not verified in fetch_leaf_der · Incorrect wolfSSL/wolfCrypt API usage
wolfSSL_check_domain_name and wolfSSL_UseSNI return values are discarded, so if the call fails the handshake at line 214 still proceeds and the peer is authenticated by chain only — any CA-issued certificate for a different host is accepted. Adjacent to known finding #11800, which omits identity registration entirely rather than ignoring its result; configure_ssl in the sibling async file checks the same call.
Related known finding #11800 (similar but distinct): Both weaken TLS peer identity authentication while retaining chain verification. #11800 omits requested-IP identity registration in tls/client-tls.c:main; this finding invokes SNI/domain binding in fetch_leaf_der but ignores setup failures before connecting. The root causes and faulting operations differ, and each needs its own patch.
Fix: Check both calls for WOLFSSL_SUCCESS and abort with the existing ssl/fd/ctx cleanup sequence on failure.
Replace the system("curl ... ") OCSP fetch in the async example with wolfSSL's EmbedOcspLookup, so the certificate-supplied URL is fetched as data over a socket instead of executed.
Both examples now target www.digicert.com (Google dropped OCSP): ocsp_nonblock
fetches the leaf live over TLS rather than a bundled cert that expires, and the async example uses wolfSSL's native async API. Bundle the DigiCert CAs and drop the expired google.pem and stale GTS certs.