Maaz2212 opened a new pull request, #14137:
URL: https://github.com/apache/trafficserver/pull/14137

   ### Summary
   This PR resolves #13985 by introducing a modern peer verification API that 
delivers peer credentials directly with verification events, enabling plugins 
to inspect both X.509 certificates and RFC 7250 Raw Public Keys (RPK) 
consistently across OpenSSL and BoringSSL.
   
   ### Background & Problem
   RFC 7250 raw public key support was added in ATS 11 (#13548). However, under 
OpenSSL, a plugin on `TS_SSL_VERIFY_CLIENT_HOOK` cannot inspect the peer's raw 
public key because:
   1. `TSVConnSslVerifyCTXGet()` returns `nullptr` on both libraries when RPK 
is negotiated.
   2. OpenSSL attaches the client's key to the session only after verification 
returns (`tls_process_client_rpk()` in `ssl/statem/statem_srvr.c`), so calling 
`SSL_get0_peer_rpk()` during the hook returns `NULL`.
   3. The legacy hook pattern relies on `TSVConnSslVerifyCTXGet()`, an internal 
state getter valid only during hook execution that ATS is moving away from.
   
   ### Proposed Changes
   1. **New Verification Hooks & Events**:
      - `TS_SSL_PEER_VERIFY_CLIENT_HOOK` (event 
`TS_EVENT_SSL_PEER_VERIFY_CLIENT`)
      - `TS_SSL_PEER_VERIFY_SERVER_HOOK` (event 
`TS_EVENT_SSL_PEER_VERIFY_SERVER`)
      - Appended at the end of the SSL hook range to maintain 100% ABI 
compatibility with all existing hook enum values.
   
   2. **Context Passed Directly with Event (`edata`)**:
      - Plugin callbacks receive `TSSslPeerVerifyCTX` directly as `edata`.
      - `tsapi_ssl_peer_verify_ctx` is stack-allocated on the event thread, 
ensuring zero heap allocation on the hot TLS handshake path.
   
   3. **Type-Safe Accessors**:
      - `TSSslPeerVerifyCTXVConnGet(ctx)`: Returns `TSVConn`.
      - `TSSslPeerVerifyCTXCredTypeGet(ctx)`: Returns `TSSslPeerCredType` 
(`TS_SSL_PEER_CRED_NONE`, `TS_SSL_PEER_CRED_X509`, `TS_SSL_PEER_CRED_RPK`).
      - `TSSslPeerVerifyCTXStoreCTXGet(ctx)`: Returns `TSSslVerifyCTX` for 
X.509 (returns `nullptr` for RPK to prevent crashes on 
`X509_STORE_CTX_get_current_cert()`).
      - `TSSslPeerVerifyCTXPeerRPKGet(ctx)`: Returns borrowed `EVP_PKEY *` 
(`get0` semantics) on both OpenSSL and BoringSSL.
      - `TSSslPeerVerifyCTXPreverifyGet(ctx)`: Returns library/pin 
preverification result (1 if valid, 0 otherwise).
   
   4. **Deprecation**:
      - `TSVConnSslVerifyCTXGet()` is marked `[[deprecated]]` in ATS 11.0.0.
   
   5. **Tests & Documentation**:
      - Added Sphinx documentation in `TSSslPeerVerifyCTX.en.rst`, updated 
`TSVConnSslVerifyCTXGet.en.rst`, `TSHttpHookID.en.rst`, and `ssl-hooks.en.rst`.
      - Added example plugin `example/plugins/c-api/peer_verify/peer_verify.cc`.
      - Added Uranium test plugin `tests/tools/plugins/ssl_peer_verify_test.cc` 
and 4 integration tests in `tests/uranium_tests/tls/test_tls_rpk_hop.py`.
   
   Fixes: #13985


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to