Skip to content

Fix receive reporting inconsistent state when a callback contaminates the error queue - #134

Merged
SeanTAllen merged 1 commit into
mainfrom
fix-alpn-queue-contamination
Aug 1, 2026
Merged

Fix receive reporting inconsistent state when a callback contaminates the error queue#134
SeanTAllen merged 1 commit into
mainfrom
fix-alpn-queue-contamination

Conversation

@SeanTAllen

Copy link
Copy Markdown
Member

SSL_get_error reports what is on the thread's error queue, not what the call did. A callback running inside SSL_do_handshake — like the ALPN select callback — can push an entry that changes SSL_get_error from SSL_ERROR_SSL to SSL_ERROR_SYSCALL without changing what actually failed.

receive routed only SSL_ERROR_SSL through _peer_auth_failed(); SSL_ERROR_SYSCALL mapped directly to SSLError. An ALPN resolver that happened to fail an OpenSSL call before returning ALPNFatal would leave a system error on the queue, shift SSL_get_error to SSL_ERROR_SYSCALL, and bypass the classification logic entirely. Both error codes now go through _peer_auth_failed(), so the reported state depends on what failed, not on what the callback happened to call.

Closes #119

@ponylang-main ponylang-main added the discuss during sync Should be discussed during an upcoming sync label Aug 1, 2026
@SeanTAllen SeanTAllen added the changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge label Aug 1, 2026
… the error queue

A callback running inside SSL_do_handshake can push an entry onto the
thread's error queue, changing what SSL_get_error returns from
SSL_ERROR_SSL to SSL_ERROR_SYSCALL without changing what actually failed.
receive routed only SSL_ERROR_SSL through _peer_auth_failed();
SSL_ERROR_SYSCALL went straight to SSLError. Both now go through
_peer_auth_failed().

Closes #119
@SeanTAllen
SeanTAllen force-pushed the fix-alpn-queue-contamination branch from c9d9260 to e50cc9e Compare August 1, 2026 23:25
@SeanTAllen
SeanTAllen merged commit 337dca0 into main Aug 1, 2026
13 checks passed
@SeanTAllen
SeanTAllen deleted the fix-alpn-queue-contamination branch August 1, 2026 23:27
@ponylang-main ponylang-main removed the discuss during sync Should be discussed during an upcoming sync label Aug 1, 2026
github-actions Bot pushed a commit that referenced this pull request Aug 1, 2026
github-actions Bot pushed a commit that referenced this pull request Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SSL.receive reports SSLError instead of SSLAuthFail when an ALPN resolver leaves an error queued

2 participants