Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
72 lines (59 loc) · 1.84 KB

File metadata and controls

72 lines (59 loc) · 1.84 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include "HTTPSServer.hpp"
namespace httpsserver {
constexpr const char * alpn_protos[] = {"http/1.1", NULL};
HTTPSServer::HTTPSServer(SSLCert * cert, const uint16_t port, const uint8_t maxConnections, const in_addr_t bindAddress):
HTTPServer(port, maxConnections, bindAddress),
_cert(cert) {
// Configure runtime data
_cfg = new esp_tls_cfg_server();
_cfg->alpn_protos = (const char **)alpn_protos;
_cfg->cacert_buf = NULL;
_cfg->cacert_bytes = 0;
_cfg->servercert_buf =cert->getCertData();
_cfg->servercert_bytes = cert->getCertLength();
_cfg->serverkey_buf= cert->getPKData();
_cfg->serverkey_bytes= cert->getPKLength();
}
HTTPSServer::~HTTPSServer() {
free(_cfg);
}
/**
* This method starts the server and begins to listen on the port
*/
uint8_t HTTPSServer::setupSocket() {
if (!isRunning()) {
_cfg->servercert_buf= _cert->getCertData();
_cfg->servercert_bytes = _cert->getCertLength();
_cfg->serverkey_buf= _cert->getPKData();
_cfg->serverkey_bytes= _cert->getPKLength();
if (HTTPServer::setupSocket()) {
return 1;
} else {
Serial.println("setupSockets failed");
return 0;
}
} else {
return 1;
}
}
void HTTPSServer::teardownSocket() {
HTTPServer::teardownSocket();
}
int HTTPSServer::createConnection(int idx) {
HTTPSConnection * newConnection = new HTTPSConnection(this);
_connections[idx] = newConnection;
return newConnection->initialize(_socket, _cfg, &_defaultHeaders);
}
/**
* This method configures the certificate and private key for the given
* ssl context
*/
uint8_t HTTPSServer::setupCert() {
// Configure the certificate first
_cfg->servercert_buf= _cert->getCertData();
_cfg->servercert_bytes = _cert->getCertLength();
_cfg->serverkey_buf= _cert->getPKData();
_cfg->serverkey_bytes= _cert->getPKLength();
return 1;
}
} /* namespace httpsserver */
Morty Proxy This is a proxified and sanitized view of the page, visit original site.