---
title: "SSL handshake fail in step MBEDTLS_SSL_CLIENT_FINISHED"
url: "https://maker.wiznet.io/forum/14504"
markdown_url: "https://maker.wiznet.io/forum/14504/md"
type: "Forum topic"
category: "Ethernet Chips"
author: "tommyliu0804"
created: "2022-03-14T12:49:16+09:00"
last_activity: "2022-03-14T12:49:16+09:00"
language: "en"
views: 318
replies: 0
source: "WIZnet Makers forum (https://maker.wiznet.io/forum/)"
---

# SSL handshake fail in step MBEDTLS_SSL_CLIENT_FINISHED

## Question

Asked by tommyliu0804 on 2022-03-14 in Ethernet Chips.

The SSL handshake was fail in step MBEDTLS_SSL_CLIENT_FINISHED, the return code of mbedtls_ssl_write_finished(ssl) was -7 which means SOCKET_CLOSED by Sn_SR.
The call stack was as following:

```
send()
WIZnetSend()
mbedtls_ssl_flush_output()
mbedtls_ssl_write_record()
mbedtls_ssl_write_handshake_msg()
mbedtls_ssl_write_finished()
mbedtls_ssl_handshake_client_step()
mbedtls_ssl_handshake()
wiz_tls_connect()
```

I also check the other registers when send fail
Sn_SR = 0x00; 2Sn_IR = 0x17; //It’s odd all the interrupt status set to 1
Sn_IMR = 0x1F; //all kinds of interrupt enabled
Sn_CR = 0x0; //no hint from command register
SIR = 0x1; // socket 0 has interrupt occurred
RTR = 0xFFFF; //max timeout
RCR = 0x09; //retry count

I doubt it’s caused by timeout. But still the same after increase the RTR to the max value before handshake. And, it also mentioned in datasheet:
If a RST packet is received from a peer during communication, Sn_SR is unconditionally changed to SOCK_CLOSED

How to make sure the RST packet was received?
Is there any hint from the registers’ value?
How to debug fail in this step and go further?

Thanks,
Tommy

---

Source: https://maker.wiznet.io/forum/14504
