server: do not resume using a ticket issued without ALPN when ALPN is negotiated

When the ticket carries an ALPN protocol, the server does not use the
ticket unless the same protocol is negotiated. But when the ticket
carried no ALPN protocol, the check was skipped entirely, and the server
resumed the session and accepted early data even if an ALPN protocol was
being negotiated (e.g., a ticket issued on a connection without ALPN
being used to send early data as "h2"). RFC 9846 Section 4.3.10 requires
the server to accept early data only when the selected ALPN protocol is
the same as the one associated with the PSK.

This commit makes the server skip the ticket in such a case as well, so
that a ticket is used only when the negotiated ALPN protocol (or the
absence of one) is the same as when the ticket was issued. Early data is
consequently rejected.

Verified with the existing tests, and with an ad-hoc test that resumes
with ALPN using a ticket obtained without ALPN (it failed before this
change).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed
tree: 2a354249bb54f75fc749686d0ec9a3b91c9d1e2b
  1. .github/
  2. cmake/
  3. deps/
  4. fuzz/
  5. include/
  6. lib/
  7. misc/
  8. picotls.xcodeproj/
  9. picotlsvs/
  10. t/
  11. .clang-format
  12. .gitignore
  13. .gitmodules
  14. appveyor.yml
  15. CMakeLists.txt
  16. picotls-probes.d
  17. README.md
  18. SECURITY.md
  19. WindowsPort.md
README.md

picotls

CI

Picotls is a TLS 1.3 (RFC 8446) protocol stack written in C, with the following features:

picotls is designed to be fast, tiny, and low-latency, with the primary user being the H2O HTTP server for serving HTTP/1, HTTP/2, and HTTP/3 over QUIC.

The TLS protocol implementation of picotls is licensed under the MIT license.

License and the cryptographic algorithms supported by the crypto bindings are as follows:

BindingLicenseKey ExchangeCertificateAEAD cipher
minicryptoCC0 / 2-clause BSDsecp256r1, x25519ECDSA (secp256r1)1AES-128-GCM, chacha20-poly1305, AEGIS-128L (using libaegis), AEGIS-256 (using libaegis)
OpenSSLOpenSSLsecp256r1, secp384r1, secp521r1, x25519RSA, ECDSA (secp256r1, secp384r1, secp521r1), ed25519AES-128-GCM, AES-256-GCM, chacha20-poly1305, AEGIS-128L (using libaegis), AEGIS-256 (using libaegis)

Note 1: Minicrypto binding is capable of signing a handshake using the certificate's key, but cannot verify a signature sent by the peer.

Building picotls

If you have cloned picotls from git then ensure that you have initialised the submodules:

% git submodule init
% git submodule update

Build using cmake:

% cmake .
% make
% make check

A dedicated documentation for using picotls with Visual Studio can be found in WindowsPort.md.

Developer documentation

Developer documentation should be available on the wiki.

Using the cli command

Run the test server (at 127.0.0.1:8443):

% ./cli -c /path/to/certificate.pem -k /path/to/private-key.pem  127.0.0.1 8443

Connect to the test server:

% ./cli 127.0.0.1 8443

Using resumption:

% ./cli -s session-file 127.0.0.1 8443

The session-file is read-write. The cli server implements a single-entry session cache. The cli server sends NewSessionTicket when it first sends application data after receiving ClientFinished.

Using early-data:

% ./cli -s session-file -e 127.0.0.1 8443

When -e option is used, client first waits for user input, and then sends CLIENT_HELLO along with the early-data.

License

The software is provided under the MIT license. Note that additional licences apply if you use the minicrypto binding (see above).

Reporting Security Issues

Please report vulnerabilities to h2o-vuln@googlegroups.com. See SECURITY.md for more information.