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

test

parent 356a4a39
Loading
Loading
Loading
Loading
+35 −2
Changes for src/ssl.cpp: 35 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -2776,8 +2776,41 @@ void netplus::ssl::handshake_after_accept(){
                if (!_aes13_hs_send || !_aes13_hs_recv)
                    throwSSL(NetException::Error, "TLS1.3 missing handshake keys");

                // 1) EncryptedExtensions (body = extension list length = 0)
                std::vector<uint8_t> ee = {0x00, 0x00};
                // 1) EncryptedExtensions - build with ALPN if negotiated
                std::vector<uint8_t> ee;
                
                if (!_selected_alpn.empty()) {
                    // Build ALPN extension (type 0x0010)
                    std::vector<uint8_t> alpn_ext;
                    
                    // Extension type: 0x0010 (ALPN)
                    alpn_ext.push_back(0x00);
                    alpn_ext.push_back(0x10);
                    
                    // Protocol list length (2 bytes)
                    uint16_t protocol_list_len = 1 + _selected_alpn.size();  // 1 byte for protocol length + protocol string
                    alpn_ext.push_back((uint8_t)(protocol_list_len >> 8));
                    alpn_ext.push_back((uint8_t)(protocol_list_len & 0xFF));
                    
                    // Extensions length (total of above)
                    uint16_t ext_len = 2 + 2 + protocol_list_len;  // type + length + data
                    
                    // Protocol length + protocol string
                    alpn_ext.push_back((uint8_t)_selected_alpn.size());
                    alpn_ext.insert(alpn_ext.end(), _selected_alpn.begin(), _selected_alpn.end());
                    
                    // Build EncryptedExtensions body: extensions_length (2 bytes) + extension data
                    ee.push_back((uint8_t)(ext_len >> 8));
                    ee.push_back((uint8_t)(ext_len & 0xFF));
                    ee.insert(ee.end(), alpn_ext.begin(), alpn_ext.end());
                    
                    std::cerr << "[SSL] EncryptedExtensions including ALPN: " << _selected_alpn << std::endl;
                } else {
                    // Empty extensions if no ALPN negotiated
                    ee = {0x00, 0x00};
                    std::cerr << "[SSL] EncryptedExtensions with no ALPN" << std::endl;
                }
                
                _tls13_send_handshake(0x08, ee, true);

                // 2) Certificate