| 40 | } |
| 41 | |
| 42 | bool Session::onAccept(TcpConnection* client, tcp_pcb* tcp) |
| 43 | { |
| 44 | debug_i("SSL %p onAccept(%p, %p)", this, client, tcp); |
| 45 | |
| 46 | if(!keyCert.isValid()) { |
| 47 | debug_e("SSL: server certificate and key are not provided!"); |
| 48 | return false; |
| 49 | } |
| 50 | |
| 51 | if(!context) { |
| 52 | assert(factory != nullptr); |
| 53 | context.reset(factory->createContext(*this)); |
| 54 | if(!context) { |
| 55 | return false; |
| 56 | } |
| 57 | |
| 58 | if(!context->init()) { |
| 59 | return false; |
| 60 | } |
| 61 | |
| 62 | // TODO: test: free the certificate data on server destroy... |
| 63 | options.freeKeyCertAfterHandshake = true; |
| 64 | } |
| 65 | |
| 66 | beginHandshake(); |
| 67 | |
| 68 | auto server = context->createServer(tcp); |
| 69 | return client->setSslConnection(server); |
| 70 | } |
| 71 | |
| 72 | bool Session::onConnect(tcp_pcb* tcp) |
| 73 | { |
nothing calls this directly
no test coverage detected