Skip to main content
function Tls.connect
def Tls.connect(
addr: str,
/,
*,
timeout_ms: None | int = None,
server_name: None | str = None,
ca_pem: None | bytes | str = None
) -> std.net.TlsStream
Connect to addr, "host:port", over TLS, and finish the handshake, all within timeout_ms; None waits as long as the OS does. The server’s certificate must be valid for server_name, by default the host part of addr, and must chain to a trusted root: the operating system’s certificate store, or, when ca_pem is given, only the certificates in it (a PEM bundle, as a string or bytes). A certificate that fails verification raises std.io.Error with kind == "invalid_data"; a ca_pem that holds no certificate, with kind == "invalid_input". function Tls.try_connect
def Tls.try_connect(
addr: str,
/,
*,
timeout_ms: None | int = None,
server_name: None | str = None,
ca_pem: None | bytes | str = None
) -> (None | std.io.Error, None | std.net.TlsStream)
connect, returning an (err, stream) pair instead of raising a std.io.Error.