-
Notifications
You must be signed in to change notification settings - Fork 8.1k
net: sockets: tls: Validate credentials when registering on a socket #97630
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
net: sockets: tls: Validate credentials when registering on a socket #97630
Conversation
7c61a20
to
9e90311
Compare
tag_found = true; | ||
|
||
switch (cred->type) { | ||
case TLS_CREDENTIAL_CA_CERTIFICATE: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should add here __fallthrough;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be, fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__fallthrough
is needed when cases have a body, for combined cases it's not needed.
Both cases are fine here:
switch (some_var) {
case 1:
/* some logic */
__fallthrough;
case 2:
/* ... */
}
switch (some_var) {
case 1:
case 2:
/* ... */
}
So far the TLS/DTLS credentials would only be validated upon first use, i. e. when TLS/DTLS handshake was initiated. This could lead to some confusion, especially when trying to understand the reason of the handshake failure, as it wasn't clear whether the handshake failed due to peer sending bad certificate or due to local configuration issues. This commit attempts to improve this, by pre-validating the credentials as soon as they are configured on a socket with TLS_SEC_TAG_LIST socket option. That way, in case bad credentials are configured on a socket, or more commonly, mbed TLS is misconfigured to handle certain credential type, it will be caught early during socket configuration, instead of during the handshake. Signed-off-by: Robert Lubos <[email protected]>
Add test cases verifying that invalid credentials are rejected by the socket when configured on TLS/DTLS socket with TLS_SEC_TAG_LIST socket option. Signed-off-by: Robert Lubos <[email protected]>
9e90311
to
9fba17b
Compare
|
So far the TLS/DTLS credentials would only be validated upon first use,
i. e. when TLS/DTLS handshake was initiated. This could lead to some
confusion, especially when trying to understand the reason of the
handshake failure, as it wasn't clear whether the handshake failed due
to peer sending bad certificate or due to local configuration issues.
This commit attempts to improve this, by pre-validating the credentials
as soon as they are configured on a socket with TLS_SEC_TAG_LIST socket
option. That way, in case bad credentials are configured on a socket, or
more commonly, mbed TLS is misconfigured to handle certain credential
type, it will be caught early during socket configuration, instead of
during the handshake.
Resolves #97541