Closed facucc closed 1 month ago
AuthN/AuthZ is deferred until after a TLS handshake succeeds. This is the expected behavior from AWS IoT.
TLS verifies that the client certificate matches its keys. After the TLS handshake, and after the first application message is received, AWS IoT will verify that the client certificate is registered on the account.
This allows for JITR, custom authentication rules, etc, to run after TLS confirms that the client certificate and keys match mathematically.
Additionally, x509 certificates without a CA can be registered on AWS IoT.
Is there a use case where a device needs to differentiate AuthN from AuthZ errors? There would be a similar Wireshark trace when connecting with a registered client certificate but use an API for which the certificate allows no authorization.
The purpose of mTLS is to perform bidirectional authentication during the TLS handshake. This means that both the client and the server must exchange and validate their certificates as part of the handshake process. Deferring the client certificate validation until after the handshake defeats the purpose of mTLS, which is to ensure both parties are authenticated before any data exchange occurs. If the server cannot validate the client's certificate, the handshake must fail immediately, preventing the connection from being established.
As @cookpate explained, this is done intentionally to support Just In-Time Registration (JITR) and other custom authentication rules. The client is still not able to exchange any data with AWS IoT with an invalid certificate. Can you share the usecase/problem that you are trying to address?
Thank you for the clarification. I understand the provisioning mechanisms such as Just-In-Time Registration (JITR) and other custom authentication rules that AWS IoT offers. However, the concept of mutual TLS (mTLS) is being incorrectly applied here.
I’m sorry for the insistence, but in accordance with the TLS protocol, the client certificate validation must occur during the handshake process. If the certificate presented by the client is invalid or unrecognized, the TLS handshake should immediately fail, rejecting the connection.
What you are suggesting is a change in AWS IoT and would break features like JITR and custom authentication. I am not sure AWS IoT would want to break these features especially when it is not causing any harm. I'll still forward this to the AWS IoT team. I am closing this issue. Feel free to re-open or create a new one if you need any more help.
AWS IoT is not rejecting invalid or unregistered certificates during the TLS handshake. Instead, it ensures certificate validity when the device tries to connect using MQTT or perform operations like publish/subscribe.
Reproducible test case
Mutual TLS also works with the same certificate using the example of mutual auth
I'm also sharing the Wireshark capture