I was wondering what the correct procedure to close a SSL connection is.
Currently, I call mbedtls_ssl_close_notify() and mbedtls_ssl_free() with the mbedtls_ssl_context.
However, if the peer has already closed the connection, mbedtls_ssl_close_notify() tries to write data and causes a SIGPIPE exception (I am on Linux). Although I can handle (ignore) this exception and continue executing, I was wondering if there is some way to avoid the exception entirely.
I guess what I’m looking for is either a way to detect if the connection was closed by the peer and don’t call mbedtls_ssl_close_notify(), or if I don’t have to call mbedtls_ssl_close_notify() at all.