Loading src/event/epoll.cpp +9 −3 Original line number Diff line number Diff line Loading @@ -109,9 +109,11 @@ namespace netplus { int next = EPOLLRDHUP | EPOLLONESHOT; // during handshake => need IN+OUT always // during handshake => need IN, and OUT only if pending writes if (!_con->csock->getHandshakeDone()) { next |= EPOLLIN | EPOLLOUT; next |= EPOLLIN; if (_con->csock->hasPendingWrite()) next |= EPOLLOUT; } else { next |= EPOLLIN; if (!_con->SendData.empty() || _con->csock->hasPendingWrite()) Loading Loading @@ -357,7 +359,11 @@ namespace netplus { } catch (NetException& e) { if (e.getErrorType() == NetException::Note){ setpollEventsFd(fd,EPOLLOUT | EPOLLIN | EPOLLRDHUP | EPOLLONESHOT); // Only set EPOLLOUT if there's actually pending write data int ev = EPOLLIN | EPOLLRDHUP | EPOLLONESHOT; if (c->csock->hasPendingWrite() || !c->SendData.empty()) ev |= EPOLLOUT; setpollEventsFd(fd, ev); return; } needClose = true; Loading src/ssl.cpp +24 −3 Original line number Diff line number Diff line Loading @@ -2238,13 +2238,23 @@ void netplus::ssl::handshake_after_accept(){ case HsState::TLS13_WAIT_CLIENT_FINISHED: { std::cerr << "[HS] TLS13_WAIT_CLIENT_FINISHED entry\n"; // ⚠️ Save transcript hash BEFORE fetching client Finished // The client computes its Finished over CH..server_Finished (not including client Finished) std::vector<uint8_t> th_before_client_finished = sha256_hash(_handshake_transcript); // wir erwarten encrypted records (outer 0x17) mit handshake keys std::vector<uint8_t> msg = _fetchNextHandshakePlain(); if (msg.empty()) return; // would block if (msg.empty()) { std::cerr << "[HS] TLS13_WAIT_CLIENT_FINISHED: msg empty, throwing Note\n"; // Must throw Note so event loop waits for more data NetException n; n[NetException::Note] << "TLS1.3: waiting for client Finished"; throw n; } std::cerr << "[HS] TLS13_WAIT_CLIENT_FINISHED: got msg size=" << msg.size() << "\n"; // msg enthält Handshake Msg (type+len24+body) if (msg.size() < 4) Loading Loading @@ -2294,6 +2304,8 @@ void netplus::ssl::handshake_after_accept(){ case HsState::TLS13_SEND_ENCRYPTED_FLIGHT: { std::cerr << "[HS] TLS13_SEND_ENCRYPTED_FLIGHT entry, queued=" << _tls13_encflight_queued << "\n"; if (!_tls13_encflight_queued) { if (!_aes13_hs_send || !_aes13_hs_recv) Loading Loading @@ -2324,14 +2336,19 @@ void netplus::ssl::handshake_after_accept(){ try { flush_out(); std::cerr << "[HS] TLS13_SEND_ENCRYPTED_FLIGHT: flush_out done, pending=" << hasPendingWrite() << "\n"; } catch(NetException& e) { if (e.getErrorType() == NetException::Note) if (e.getErrorType() == NetException::Note) { std::cerr << "[HS] TLS13_SEND_ENCRYPTED_FLIGHT: flush_out Note, returning\n"; return; } throw; } if (!hasPendingWrite()) if (!hasPendingWrite()) { std::cerr << "[HS] TLS13_SEND_ENCRYPTED_FLIGHT: transition to WAIT_CLIENT_FINISHED\n"; _hs_state = HsState::TLS13_WAIT_CLIENT_FINISHED; } return; } Loading Loading @@ -3586,8 +3603,12 @@ size_t netplus::ssl::recvData(buffer& data, int flags) // ============================================================ for (int attempts = 0; attempts < 4; ++attempts) { std::cerr << "[recvData] attempt=" << attempts << " calling readTlsRecordAsync\n"; std::vector<uint8_t> rec = readTlsRecordAsync(); // may throw Note std::cerr << "[recvData] got rec size=" << rec.size() << "\n"; if (rec.size() < 5) throwSSL(NetException::Error, "TLS record too short"); Loading Loading
src/event/epoll.cpp +9 −3 Original line number Diff line number Diff line Loading @@ -109,9 +109,11 @@ namespace netplus { int next = EPOLLRDHUP | EPOLLONESHOT; // during handshake => need IN+OUT always // during handshake => need IN, and OUT only if pending writes if (!_con->csock->getHandshakeDone()) { next |= EPOLLIN | EPOLLOUT; next |= EPOLLIN; if (_con->csock->hasPendingWrite()) next |= EPOLLOUT; } else { next |= EPOLLIN; if (!_con->SendData.empty() || _con->csock->hasPendingWrite()) Loading Loading @@ -357,7 +359,11 @@ namespace netplus { } catch (NetException& e) { if (e.getErrorType() == NetException::Note){ setpollEventsFd(fd,EPOLLOUT | EPOLLIN | EPOLLRDHUP | EPOLLONESHOT); // Only set EPOLLOUT if there's actually pending write data int ev = EPOLLIN | EPOLLRDHUP | EPOLLONESHOT; if (c->csock->hasPendingWrite() || !c->SendData.empty()) ev |= EPOLLOUT; setpollEventsFd(fd, ev); return; } needClose = true; Loading
src/ssl.cpp +24 −3 Original line number Diff line number Diff line Loading @@ -2238,13 +2238,23 @@ void netplus::ssl::handshake_after_accept(){ case HsState::TLS13_WAIT_CLIENT_FINISHED: { std::cerr << "[HS] TLS13_WAIT_CLIENT_FINISHED entry\n"; // ⚠️ Save transcript hash BEFORE fetching client Finished // The client computes its Finished over CH..server_Finished (not including client Finished) std::vector<uint8_t> th_before_client_finished = sha256_hash(_handshake_transcript); // wir erwarten encrypted records (outer 0x17) mit handshake keys std::vector<uint8_t> msg = _fetchNextHandshakePlain(); if (msg.empty()) return; // would block if (msg.empty()) { std::cerr << "[HS] TLS13_WAIT_CLIENT_FINISHED: msg empty, throwing Note\n"; // Must throw Note so event loop waits for more data NetException n; n[NetException::Note] << "TLS1.3: waiting for client Finished"; throw n; } std::cerr << "[HS] TLS13_WAIT_CLIENT_FINISHED: got msg size=" << msg.size() << "\n"; // msg enthält Handshake Msg (type+len24+body) if (msg.size() < 4) Loading Loading @@ -2294,6 +2304,8 @@ void netplus::ssl::handshake_after_accept(){ case HsState::TLS13_SEND_ENCRYPTED_FLIGHT: { std::cerr << "[HS] TLS13_SEND_ENCRYPTED_FLIGHT entry, queued=" << _tls13_encflight_queued << "\n"; if (!_tls13_encflight_queued) { if (!_aes13_hs_send || !_aes13_hs_recv) Loading Loading @@ -2324,14 +2336,19 @@ void netplus::ssl::handshake_after_accept(){ try { flush_out(); std::cerr << "[HS] TLS13_SEND_ENCRYPTED_FLIGHT: flush_out done, pending=" << hasPendingWrite() << "\n"; } catch(NetException& e) { if (e.getErrorType() == NetException::Note) if (e.getErrorType() == NetException::Note) { std::cerr << "[HS] TLS13_SEND_ENCRYPTED_FLIGHT: flush_out Note, returning\n"; return; } throw; } if (!hasPendingWrite()) if (!hasPendingWrite()) { std::cerr << "[HS] TLS13_SEND_ENCRYPTED_FLIGHT: transition to WAIT_CLIENT_FINISHED\n"; _hs_state = HsState::TLS13_WAIT_CLIENT_FINISHED; } return; } Loading Loading @@ -3586,8 +3603,12 @@ size_t netplus::ssl::recvData(buffer& data, int flags) // ============================================================ for (int attempts = 0; attempts < 4; ++attempts) { std::cerr << "[recvData] attempt=" << attempts << " calling readTlsRecordAsync\n"; std::vector<uint8_t> rec = readTlsRecordAsync(); // may throw Note std::cerr << "[recvData] got rec size=" << rec.size() << "\n"; if (rec.size() < 5) throwSSL(NetException::Error, "TLS record too short"); Loading