Skip to content
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

Handshake failure due to ticket arrival #8591

Closed
irwir opened this issue Dec 2, 2023 · 4 comments
Closed

Handshake failure due to ticket arrival #8591

irwir opened this issue Dec 2, 2023 · 4 comments
Labels
bug component-tls13 priority-high High priority - will be reviewed soon size-s Estimated task size: small (~2d)

Comments

@irwir
Copy link
Contributor

irwir commented Dec 2, 2023

Summary

Testing sls_mail_client.c with locally installed hMailServer (based on OpenSSL library).
Server cannot be connected due to handshake failure.

System information

Mbed TLS version 3.5.0
Operating system and version: Windows 11
Compiler: Visual Studio 2022

Expected behavior

Successful mail exchange.

Actual behavior

When handshaking gets to MBEDTLS_SSL_HANDSHAKE_OVER state, the mail server sends a ticket.
Now, since the step returned with a non-zero state MBEDTLS_ERR_SSL_RECEIVED_NEW_SESSION_TICKET, handshaking got aborted.

Additional information

ret = mbedtls_ssl_tls13_handshake_client_step(ssl);

This addition quickly patched the issue, but the problem might be deeper:

if (ret == MBEDTLS_ERR_SSL_RECEIVED_NEW_SESSION_TICKET &&
ssl->state == MBEDTLS_SSL_HANDSHAKE_OVER) {
ret = 0;
}

@yanrayw yanrayw added bug component-tls13 size-s Estimated task size: small (~2d) priority-high High priority - will be reviewed soon labels Dec 4, 2023
@ronald-cron-arm
Copy link
Contributor

ronald-cron-arm commented Jan 17, 2024

Thanks a lot for the report. The quick patch basically disables the reception of TLS 1.3 session tickets by applications thus we cannot to that. I see two possible ways forward:

  1. ignoring in your application code (mail client it seems) the MBEDTLS_ERR_SSL_RECEIVED_NEW_SESSION_TICKET returned value (can be returned by mbedtls_ssl_handshake_step(), mbedtls_ssl_handshake() and mbedtls_ssl_read()).
  2. disabling the MBEDTLS_SSL_SESSION_TICKETS configuration option when you build the Mbed TLS library for your mail client. I know that we have some pending issues around that but we are aiming to fix them shortly.

@irwir
Copy link
Contributor Author

irwir commented Jan 17, 2024

The is MbedTLS example mail client. It has got changes for TLS 1.3, but more than one issue was encountered.

1. ignoring in your application code (mail client it seems) the MBEDTLS_ERR_SSL_RECEIVED_NEW_SESSION_TICKET returned value (can be returned by mbedtls_ssl_handshake_step(), mbedtls_ssl_handshake() and mbedtls_ssl_read()).

The client calls mbedtls_ssl_handshake(), and one of the steps (not the last) fails inside the library code.
Should the remaining steps be skipped, the connection might end up having a wrong state.
Hence the patch was a natural choice.

Hopefully, the issue would be properely resolved soon.

@irwir
Copy link
Contributor Author

irwir commented Feb 24, 2024

My basic understanding of ticket handling is that server sends a ticket when a handshake had been completed successfully.
Client could store the ticket and might use it for future fast reconnects.
But only ssl_tls13_server.c has processing in MBEDTLS_SSL_TLS1_3_NEW_SESSION_TICKET state, while there is nothing in the corresponding client module.
That server processing routine restarts (an already completed) handshaking, which is not what the client side needs.

@irwir
Copy link
Contributor Author

irwir commented Mar 1, 2024

After the commit 9b4e964 mail application could successfully connect and send an email.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug component-tls13 priority-high High priority - will be reviewed soon size-s Estimated task size: small (~2d)
Projects
Status: [3.6] TLS 1.3 misc for LTS
Development

No branches or pull requests

3 participants