OmniNet 0.7.2: 5 codemax TLS bug fixes
Commits since 0.7.1:
45cae5b Fix Bug 3: TLSSocket::readLine() overrides base
Previously, calling readLine() on a TLSSocket used the inherited
Socket::readLine() which calls raw ::recv() on the underlying fd,
bypassing SSL_read. The result was raw TLS ciphertext (the
record header bytes) which looked like 'malformed status line'
to text-line parsers. Override readLine() to use the overridden
recv() (which goes through SSL_read), one byte at a time.
fc97be9 Fix Bug 4: load system CA + SSL_VERIFY_PEER by default
Previously, initContext() created an SSL_CTX but didn't load any
CA certs and didn't set a verify mode. OpenSSL's default is
SSL_VERIFY_NONE, and setVerifyMode(PEER) on its own doesn't
load the CA store. So setVerifyMode(PEER) + connect() would
silently accept forged certificates. Fix: in initContext(),
for client contexts, call SSL_CTX_set_default_verify_paths()
and SSL_CTX_set_verify(m_ctx, SSL_VERIFY_PEER, nullptr).
Callers can still override via setVerifyMode(NONE).
913e44b Fix Bug 1 + 5: implement TLSContext::createClient/createSocket
Previously, TLSContext::createClient() and createSocket() were
declared but never defined - link failed with 'undefined
reference'. createServer() was also unimplemented. Made
TLSContext inherit std::enable_shared_from_this so createSocket()
can use shared_from_this(). Implemented createServer(),
createClient(), createSocket(), and the private ctor + dtor.
Added TLSSocket(shared_ptr<TLSContext>) constructor and
setContext() helper for adopting a shared context.
d508494 Fix Bug 2: setALPNProtocols() actually sets ALPN
Previously, setALPNProtocols() was a no-op stub. Without ALPN,
modern HTTPS servers (Cloudflare, GitHub, Google) default to
HTTP/2 which has a binary wire format incompatible with text-line
HTTP/1.1 parsers - resulting in garbage status lines like
'PRI * HTTP/2.0'. Fix: build the ALPN wire format (RFC 7301)
and call SSL_CTX_set_alpn_protos() on m_ctx. getALPNProtocol()
was already implemented correctly.
Plus: CodeMax.md updates tracking the work.
Tests: test_omnet_test 110/110 PASS, test_sync_http_server 18/18 PASS.
Full build clean, zero warnings. All 5 codemax integration bugs fixed.