Skip to content

Return original wolfSSL error from getError() instead of SSL_ERROR_SYSCALL - #442

Merged
rlm2002 merged 1 commit into
wolfSSL:masterfrom
cconlon:jsseUnconvertedErrors
Oct 23, 2026
Merged

rlm2002 merged 1 commit into
wolfSSL:masterfrom
cconlon:jsseUnconvertedErrors

Conversation

@cconlon

@cconlon cconlon commented Oct 20, 2026

Copy link
Copy Markdown
Member

This PR changes WolfSSLSession.getError() to return the original wolfSSL error for MATCH_SUITE_ERROR (-501) and SOCKET_PEER_CLOSED_E (-397). With OPENSSL_EXTRA (enabled by --enable-jni), wolfSSL_get_error() converts both to SSL_ERROR_SYSCALL (5), which hides the real cause.

Fixes

  • SSLSocket/Engine cipher suite mismatches now report -501 instead of "fatal I/O error in TLS layer (error code: 5)"
  • SSLSocket read() now returns -1 instead of 0 when the peer closes the connection without sending close_notify

Also adds WolfSSL.MATCH_SUITE_ERROR and tests for both cases.

Behavior change: on OPENSSL_EXTRA builds, applications that call getError() directly now get MATCH_SUITE_ERROR or SSL_ERROR_SOCKET_PEER_CLOSED instead of SSL_ERROR_SYSCALL in these two cases.

Copilot AI balanced review requested due to automatic review settings October 20, 2026 22:40

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot 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.

Fenrir Automated Review — PR #442

Scan targets checked: wolfssljni-src, wolfssljni-bugs
Coverage: 1 of 7 in-scope changed file(s) opened by the reviewer; not opened: native/com_wolfssl_WolfSSL.h, src/java/com/wolfssl/WolfSSL.java, src/java/com/wolfssl/WolfSSLSession.java, src/test/com/wolfssl/provider/jsse/test/WolfSSLEngineTest.java, src/test/com/wolfssl/provider/jsse/test/WolfSSLSocketTest.java, src/test/com/wolfssl/test/WolfSSLSessionTest.java

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

Review tier: Lite

@cconlon

cconlon commented Oct 20, 2026

Copy link
Copy Markdown
Member Author

@claude review

@claude claude Bot 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.

I reviewed this PR and didn't find any bugs. On OPENSSL_EXTRA builds it changes what the public WolfSSLSession.getError() returns, and two earlier reviews are still on the thread, so a human look would still be worthwhile.

What was reviewed:

  • The native getError remap: wolfSSL_state() is only checked when the result is SSL_ERROR_SYSCALL, and a NULL ssl returns before that branch. Both error macros come from the already-included wolfssl/error-ssl.h.
  • Callers in src/java: nothing compares against SSL_ERROR_SYSCALL. WolfSSLSocket.read() already maps SSL_ERROR_SOCKET_PEER_CLOSED with ret == 0 to end of stream, so the -1 fix follows from the remap.
  • The new MATCH_SUITE_ERROR (-501) constant matches its define in native/com_wolfssl_WolfSSL.h. The new tests skip when the needed suites are missing and stay within Java 8.
Extended reasoning...

The change touches the JNI error-reporting path in native/com_wolfssl_WolfSSLSession.c, adds one public constant, and adds JUnit tests at the JNI, SSLSocket and SSLEngine layers. It doesn't touch any auth or key handling. It does change what a public API returns: OPENSSL_EXTRA builds now get -501 or -397 instead of 5, which can affect applications that check for SSL_ERROR_SYSCALL. Two earlier bot reviews (COMMENTED) came in with no later commit, and I can't see what they said, so approval is not appropriate.

@cconlon cconlon self-assigned this Oct 21, 2026
@cconlon
cconlon force-pushed the jsseUnconvertedErrors branch from 61bbb74 to 62b90e0 Compare October 22, 2026 18:43
@cconlon cconlon assigned rlm2002 and wolfSSL-Bot and unassigned cconlon Oct 22, 2026
@rlm2002
rlm2002 merged commit 693c2be into wolfSSL:master Oct 23, 2026
109 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.

5 participants