10000 Fixed a bug that caused rebooting when SSL handshake failed · quentin/esp32_https_server@0936e38 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0936e38

Browse files
committed
Fixed a bug that caused rebooting when SSL handshake failed
1 parent 28a16b7 commit 0936e38

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

https/HTTPSConnection.cpp

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,26 @@ int HTTPSConnection::initialize(int serverSocketID, SSL_CTX * sslCtx, HTTPHeader
4848

4949
_ssl = SSL_new(sslCtx);
5050

51-
// Bind SSL to the socket
52-
int success = SSL_set_fd(_ssl, _socket);
53-
if (success) {
54-
55-
// Perform the handshake
56-
success = SSL_accept(_ssl);
51+
if (_ssl) {
52+
// Bind SSL to the socket
53+
int success = SSL_set_fd(_ssl, _socket);
5754
if (success) {
58-
_connectionState = STATE_INITIAL;
59-
_httpHeaders = new HTTPHeaders();
60-
refreshTimeout();
61-
return _socket;
55+
56+
// Perform the handshake
57+
success = SSL_accept(_ssl);
58+
if (success) {
59+
_connectionState = STATE_INITIAL;
60+
_httpHeaders = new HTTPHeaders();
61+
refreshTimeout();
62+
return _socket;
63+
} else {
64+
HTTPS_DLOG("[ERR] SSL_accept failed. Aborting handshake.");
65+
}
66+
} else {
67+
HTTPS_DLOG("[ERR] SSL_set_fd failed. Aborting handshake.");
6268
}
69+
} else {
70+
HTTPS_DLOG("[ERR] SSL_new failed. Aborting handshake.");
6371
}
6472
}
6573
_connectionState = STATE_ERROR;

0 commit comments

Comments
 (0)
0