Skip to content

net: sockets: tls: Add new options for certificate verification #90068

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

rlubos
Copy link
Collaborator

@rlubos rlubos commented May 16, 2025

Add new TLS socket options:

  • TLS_CERT_VERIFY_RESULT to retrieve certificate verification result,
  • TLS_CERT_VERIFY_CALLBACK to regsiter ceritificate verification callback.

Plus associated tests.

Resolves #52541

rlubos added 3 commits May 16, 2025 14:42
Add new TLS socket option, TLS_CERT_VERIFY_RESULT, to obtain the
certificate verification result from the most recent handshake on the
socket. The option works if TLS_PEER_VERIFY_OPTIONAL was set on the
socket, in which case the handshake may succeed even if certificate
verification fails.

Signed-off-by: Robert Lubos <[email protected]>
Extract server configuration, client configuration and test shutdown
into separate functions so that they're reusable in other tests.

Signed-off-by: Robert Lubos <[email protected]>
Add test case to verify if TLS_CERT_VERIFY_RESULT socket option works as
expected.

Signed-off-by: Robert Lubos <[email protected]>
rlubos added 2 commits May 16, 2025 15:49
Add new TLS socket option, TLS_CERT_VERIFY_CALLBACK, which allows to
register an application callback to verify certificates obtained during
the TLS handshake.

Signed-off-by: Robert Lubos <[email protected]>
Add test case to verify if TLS_CERT_VERIFY_CALLBACK socket option works
as expected.

Signed-off-by: Robert Lubos <[email protected]>
@rlubos rlubos force-pushed the net/tls-cert-verify-opts branch from fa5c83c to fc6641d Compare May 16, 2025 13:49
}

cert_verify = (struct tls_cert_verify_cb *)optval;
if (cert_verify->cb == NULL && cert_verify->ctx != NULL) {
Copy link
Member

Choose a reason for hiding this comment

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

Why do we care what the ctx is here, or was the idea that user can unset the callback by setting both values null (this is not documented if that is the idea)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

net: sockets: tls: Check whether peer was verified after handshake (with TLS_PEER_VERIFY_OPTIONAL)
2 participants