Skip to content

wolfssl: handle ASN_PARSE_E returned by wolfSSL 5.9.2 - #22175

Closed
vszakats wants to merge 5 commits into
curl:masterfrom
vszakats:wolfpeer
Closed

vszakats wants to merge 5 commits into
curl:masterfrom
vszakats:wolfpeer

Conversation

@vszakats

@vszakats vszakats commented Jun 25, 2026 •

Copy link
Copy Markdown
Member

wolfSSL 5.9.2 started returning a new code on bad ASN input. Catch it in
curl and return CURLE_PEER_FAILED_VERIFICATION, to avoid the generic
error handler path returning CURLE_COULDNT_CONNECT, also breaking test
311.

ASN_PARSE_E is present in the earliest supported wolfSSL (5.0.0).

Fixing:

test 0311...[HTTPS wrong subjectAltName but right CN]
curl returned 7, when expecting 60
 311: exit FAILED
[...]
 curl: (35) SSL_connect failed with error -140: ASN parsing error, invalid input

In CI jobs:
Linux / AM wolfssl-all
Linux / AM wolfssl-opensslextra valgrind 1
Linux HTTP/3 / CM wolfssl

Bug: #22160 (comment)
Ref: #22160


Tested OK with #22160 applied:
https://github.com/curl/curl/actions/runs/28186561610/job/83489932278
https://github.com/curl/curl/actions/runs/28186561610/job/83489932261
https://github.com/curl/curl/actions/runs/28186561580/job/83490299954?pr=22175

@github-actions github-actions Bot added the TLS label Jun 25, 2026
@vszakats
vszakats marked this pull request as draft June 25, 2026 16:50
@github-actions github-actions Bot added the CI Continuous Integration label Jun 25, 2026
@vszakats
vszakats marked this pull request as ready for review June 25, 2026 17:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates curl’s wolfSSL backend handshake error handling to recognize wolfSSL’s ASN_PARSE_E (seen with wolfSSL 5.9.2 on bad ASN input) and map it to CURLE_PEER_FAILED_VERIFICATION, aligning the return code with certificate/verification failures and restoring expected behavior for test 0311.

Changes:

  • Add explicit handling for ASN_PARSE_E returned by wolfSSL_get_error() during wolfSSL_connect().
  • Return CURLE_PEER_FAILED_VERIFICATION (instead of falling through to the generic SSL error path) when ASN parsing fails.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/vtls/wolfssl.c Resolved
@bagder

bagder commented Jun 25, 2026

Copy link
Copy Markdown
Member

I'm not sure treating such a generic ASN.1 problem as a failed verification is what we should do. It seems to be possible to get this error for a very large variety of different ASN1 errors. I would probably argue that it is wrong for wolfSSL to return this error for this problem as the ASN1 is fine, it just has a combo of data that does not match.

@vszakats

vszakats commented Jun 25, 2026 •

Copy link
Copy Markdown
Member Author

This was based on the assumption that the wolfSSL fix is here to stay, as
a result of a CVE and now validating input more stricly.

I guess then we just skip this wolfSSL version and bump once it's fixed?

Closing this one, since I have no better proposal.

edit: there were a number of changes to ASN handling and new conditions returning this error; it might not have been a CVE fix after all.

@vszakats vszakats closed this Jun 25, 2026
@vszakats
vszakats deleted the wolfpeer branch June 25, 2026 22:18
@bagder

bagder commented Jun 26, 2026

Copy link
Copy Markdown
Member

I guess then we just skip this wolfSSL version and bump once it's fixed?

Assuming they think it is a problem and will fix it, sure, otherwise we need to do something.

vszakats added a commit that referenced this pull request Jul 2, 2026
Apply upstream patch to fix a regression in 5.9.2.

Refs:
wolfSSL/wolfssl#10790
wolfSSL/wolfssl#10793
wolfSSL/wolfssl@7dd269f

Ref: #22175 (local mitigation attempt)
Fixes #22160

Closes #22204
vszakats pushed a commit that referenced this pull request Jul 9, 2026
Homebrew is distributing v5.9.2 at the time of this commit, which
contains known regression failing to parse the server certificate.
The fix has been merged upstream. Till it makes it into a release
and Homebrew, ignore test results for 311.

Refs:
wolfSSL/wolfssl#10793
wolfSSL/wolfssl@7dd269f

Follow-up to 03f9751 #22204 #22175 #22160
Closes #22269
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI Continuous Integration TLS

Development

Successfully merging this pull request may close these issues.

3 participants