Open mpg opened 1 week ago
Cc @gilles-peskine-arm as you introduced this test so you might have ideas.
The test as a whole didn't take particularly long, so this looks like a race condition, not a timeout.
The error indicates that the server expected to close the connection, but the client had already closed it. I encountered several problems like this when I was writing those tests, but not with ssl_pthread_server
.
I did encounter a race condition in ssl_pthread_server
, but it was of a different kind: 3abca9510a7fb40688a2be115e41e93c15f3b38b to avoid some missing logs.
Note that although ssl_pthread_server
is multithreaded, the test only connects a single client, so the only concurrency should be between the server and the client, there shouldn't be any non-determinism inside the server.
A tempting workaround would be to ignore errors (or at least this error) in mbedtls_ssl_close_notify
. I'm always weary of silencing an error that I don't fully understand: this could be a genuine bug in closing connections. But we could accept that closing connections (which happens a lot in the real world!) is something we don't test enough, and let the current testing focus on the ability to establish a connection. Testing the ability to establish a connection was the driving goal of adding the test cases in sample.sh
.
I think ignoring this particular error (but not other errors) in close_notify
would make sense - and probably not just as a work-around, also as a real-world practice. From the RFC:
Both parties need not wait to receive a "close_notify" alert before closing their read side of the connection
If the other party sends its close_notify
and immediately closes their (read side of the) connection, I think the symptom is going to be exactly this: when we try sending our close_notify
we'll get NET - Connection was reset by peer
.
Observed on:
Output from
ssl-opt.sh
:Problematic excerpt from server log: