Tls_configTLS configuration utilities
This module provides shared TLS configuration creation to ensure consistent behavior across session-based and one-shot request modes.
Supports ALPN (Application-Layer Protocol Negotiation) for HTTP/2 upgrade per RFC 9113 Section 3.3.
val src : Logs.srcLogs source for this module
Minimum TLS version configuration. Per Recommendation #6: Allow enforcing minimum TLS version.
val tls_version_to_tls : tls_version -> Tls.Core.tls_versionConvert our TLS version type to the underlying library's type
Per RFC 9113 Section 3.3, HTTP/2 connections over TLS use ALPN to negotiate the protocol.
val alpn_protocols : protocol_mode -> string listalpn_protocols mode returns the ALPN protocol list for the given mode.
"h2"; "http/1.1""http/1.1""h2"val create_client :
?verify_tls:bool ->
?min_tls_version:tls_version ->
?protocol_mode:protocol_mode ->
host:string ->
unit ->
Tls.Config.clientcreate_client ~host () creates a TLS client configuration.
val create_client_opt :
?existing_config:Tls.Config.client ->
verify_tls:bool ->
min_tls_version:tls_version ->
?protocol_mode:protocol_mode ->
host:string ->
unit ->
Tls.Config.client optioncreate_client_opt ~verify_tls ~min_tls_version ~host () creates a TLS client configuration, or returns the existing one if provided.
Helper functions for extracting negotiated protocol from TLS epoch.
Negotiated HTTP protocol from ALPN.
val get_alpn_from_epoch : Tls.Core.epoch_data -> string optionget_alpn_from_epoch epoch extracts the negotiated ALPN protocol from TLS epoch data. Returns None if ALPN was not negotiated.
val negotiated_of_alpn : string -> negotiated_protocol optionnegotiated_of_alpn alpn parses ALPN result string.
val default_protocol : negotiated_protocolDefault protocol (HTTP/1.1) when ALPN is not available.
val detect_protocol :
mode:protocol_mode ->
string option ->
negotiated_protocoldetect_protocol ~mode alpn_result determines the protocol to use.
val negotiated_to_string : negotiated_protocol -> stringConvert negotiated protocol to string ("HTTP/1.1" or "HTTP/2").
val pp_negotiated : Format.formatter -> negotiated_protocol -> unitPretty print negotiated protocol.