Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -2595,7 +2595,10 @@ static int TLSX_SNI_VerifyParse(WOLFSSL* ssl, byte isRequest)
continue;
}

SendAlert(ssl, alert_fatal, handshake_failure);
SendAlert(ssl, alert_fatal,
IsAtLeastTLSv1_3(ssl->version)
? missing_extension
: handshake_failure);
Comment on lines +2598 to +2601
Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

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

The TLS-version-dependent alert selection logic is duplicated across both error branches. To reduce repetition and keep future protocol tweaks consistent, consider computing the chosen alert once (e.g., a local int alert = ...) and reusing it in both places, or extracting a small helper for 'SNI required' alert selection.

Copilot uses AI. Check for mistakes.
WOLFSSL_ERROR_VERBOSE(SNI_ABSENT_ERROR);
return SNI_ABSENT_ERROR;
}
Expand All @@ -2606,7 +2609,10 @@ static int TLSX_SNI_VerifyParse(WOLFSSL* ssl, byte isRequest)
if (ssl_sni->status != WOLFSSL_SNI_NO_MATCH)
continue;

SendAlert(ssl, alert_fatal, handshake_failure);
SendAlert(ssl, alert_fatal,
IsAtLeastTLSv1_3(ssl->version)
? missing_extension
: handshake_failure);
Comment on lines +2612 to +2615
Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

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

missing_extension is intended for cases where a required extension is absent. In this branch, the SNI extension appears to be present but has WOLFSSL_SNI_NO_MATCH, so missing_extension is likely the wrong alert for TLS 1.3+. Consider using an alert that reflects 'name not recognized' (commonly unrecognized_name per RFC 6066) for the NO_MATCH case, and reserve missing_extension for the truly-absent-extension branch.

Copilot uses AI. Check for mistakes.
Comment on lines +2612 to +2615
Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

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

The TLS-version-dependent alert selection logic is duplicated across both error branches. To reduce repetition and keep future protocol tweaks consistent, consider computing the chosen alert once (e.g., a local int alert = ...) and reusing it in both places, or extracting a small helper for 'SNI required' alert selection.

Copilot uses AI. Check for mistakes.
WOLFSSL_ERROR_VERBOSE(SNI_ABSENT_ERROR);
return SNI_ABSENT_ERROR;
}
Expand Down
Loading