Commit cc211813 authored by jan.koester's avatar jan.koester
Browse files

test

parent 1f32e5b7
Loading
Loading
Loading
Loading
+21 −0
Changes for src/ssl.cpp: 21 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -641,10 +641,31 @@ void netplus::ssl::accept(std::unique_ptr<socket> &csock) {
        cssock->_send_seq++; // ✅ exactly once per sent record
    };

    auto dumpRecHeader = [&](const std::vector<uint8_t>& rec, const char* tag) {
        if (rec.size() < 5) return;
        uint8_t ct = rec[0];
        uint16_t ver = (rec[1] << 8) | rec[2];
        uint16_t len = (rec[3] << 8) | rec[4];
        std::cerr << tag
                << " CT=0x" << std::hex << (int)ct
                << " VER=0x" << ver
                << " LEN=" << std::dec << len;
        if (ct == 0x15 && rec.size() >= 7) { // Alert
            std::cerr << " ALERT(level=" << (int)rec[5] << ", desc=" << (int)rec[6] << ")";
        }
        if (ct == 0x16 && rec.size() >= 6) { // Handshake
            std::cerr << " HS(type=0x" << std::hex << (int)rec[5] << ")";
        }
        std::cerr << std::dec << "\n";
    };

    // ---- Handshake -----------------------------------------------------------
    try {
        // 1) Read ClientHello (Handshake record)
        std::vector<uint8_t> chRec = readTlsRecord();

        dumpRecHeader(chRec, "NEXT REC");

        if (chRec.size() < 5 + 4 + 2 + 32 || chRec[0] != 0x16 || chRec[5] != 0x01) {
            throwSSL(netplus::NetException::Error, "Expected ClientHello");
        }