Skip to content

fix: add getsockopt shim and TLS SNI fix for curl WASM#1427

Open
airhorns wants to merge 1 commit intorivet-dev:mainfrom
airhorns:fix/curl-wasm-getsockopt-tls
Open

fix: add getsockopt shim and TLS SNI fix for curl WASM#1427
airhorns wants to merge 1 commit intorivet-dev:mainfrom
airhorns:fix/curl-wasm-getsockopt-tls

Conversation

@airhorns
Copy link
Copy Markdown

@airhorns airhorns commented Apr 2, 2026

curl WASM tests were failing with exit code 7 (CURLE_COULDNT_CONNECT) because getsockopt() was not implemented in the WASI socket layer. curl calls getsockopt(SO_ERROR) after connect to verify the connection, and without it verifyconnect() always returned false.

Additionally, HTTPS tests failed with exit code 35 (CURLE_SSL_CONNECT_ERROR) because Node.js rejects TLS servername (SNI) set to an IP address. The driver now skips SNI for IP address hostnames.

Changes:

  • Add wasi_getsockopt.c overlay that routes getsockopt through host_net
  • Update build-curl-upstream.sh to compile and link the new shim
  • Skip TLS servername for IP addresses in driver.ts (net.isIP check)
  • Add missing WASI errno constants: EINPROGRESS, ENOTCONN, EMFILE, EMSGSIZE

curl WASM tests were failing with exit code 7 (CURLE_COULDNT_CONNECT)
because getsockopt() was not implemented in the WASI socket layer. curl
calls getsockopt(SO_ERROR) after connect to verify the connection, and
without it verifyconnect() always returned false.

Additionally, HTTPS tests failed with exit code 35 (CURLE_SSL_CONNECT_ERROR)
because Node.js rejects TLS servername (SNI) set to an IP address. The
driver now skips SNI for IP address hostnames.

Changes:
- Add wasi_getsockopt.c overlay that routes getsockopt through host_net
- Update build-curl-upstream.sh to compile and link the new shim
- Skip TLS servername for IP addresses in driver.ts (net.isIP check)
- Add missing WASI errno constants: EINPROGRESS, ENOTCONN, EMFILE, EMSGSIZE
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.

1 participant