Skip to content

wolfssl: require a peer certificate when verifying - #23503

Closed
matty69v wants to merge 1 commit into
curl:masterfrom
matty69v:wolfssl-anon-cert
Closed

matty69v wants to merge 1 commit into
curl:masterfrom
matty69v:wolfssl-anon-cert

Conversation

@matty69v

Copy link
Copy Markdown
Contributor

With an anonymous cipher suite the server sends no certificate. wolfSSL then completes the handshake and neither WOLFSSL_VERIFY_PEER nor wolfSSL_check_domain_name() has anything to check, so curl accepted the connection even with CURLOPT_SSL_VERIFYPEER and CURLOPT_SSL_VERIFYHOST enabled. Only the IP address path checked for a missing certificate.

This moves the missing certificate check out of the IP address block so it runs whenever verifypeer or verifyhost is set. The IP match check is unchanged.

Tested with wolfSSL 5.9.4 (--enable-distro) and 5.6.6: an anonymous DH server is now refused with CURLE_PEER_FAILED_VERIFICATION, CA signed servers by hostname and IP, TLS 1.2 and 1.3 and session resumption work as before, HTTPS/FTPS tests pass

With an anonymous cipher suite the server sends no certificate. wolfSSL
then completes the handshake and neither WOLFSSL_VERIFY_PEER nor
wolfSSL_check_domain_name() has anything to check, so curl accepted the
connection even with CURLOPT_SSL_VERIFYPEER and CURLOPT_SSL_VERIFYHOST
enabled. Only the IP address path checked for a missing certificate.

wolfSSL builds with HAVE_ANON and OPENSSL_COMPATIBLE_DEFAULTS, such as
--enable-distro, offer anonymous suites by default.

Require a peer certificate whenever verifypeer or verifyhost is set.
Copilot AI balanced review requested due to automatic review settings October 20, 2026 09:47
@github-actions github-actions Bot added the TLS label Oct 20, 2026

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.

🟡 Changes recommended

Automated regression coverage is needed for certificate-less handshakes across verification-option combinations.

1 open issue
What changed in this PR

This PR closes a wolfSSL certificate-verification bypass for anonymous TLS connections in curl.

Changes:

  • Requires a peer certificate when either peer or hostname verification is enabled.
  • Preserves the existing IP-address certificate check.
File Description
lib/​vtls/​wolfssl.c Extends the missing-certificate check beyond IP-address connections.

Review effort: Balanced

Comment thread lib/vtls/wolfssl.c
Comment on lines 1721 to +1722
if(ret == WOLFSSL_SUCCESS &&
conn_config->verifyhost &&
!connssl->peer.sni) {
/* we have an IP address as hostname. */
(conn_config->verifypeer || conn_config->verifyhost)) {
@bagder bagder closed this in 5133603 Oct 20, 2026
@bagder

bagder commented Oct 20, 2026

Copy link
Copy Markdown
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

3 participants