Xo is experimental. The source is now public on GitHub, or try Xo in your browser.
Menu · tls

Docs

std/tls

On this page

Index

Types

Verify

enum Verify {
  Full
  ChainOnly
  None
} derive Display

How the server’s certificate is checked (std.md 27).

Source: std/tls.xo:9

Roots

struct Roots {}

Certificates a client trusts (std.md 27); a handle.

Source: std/tls.xo:16

TlsErr

struct TlsErr {
  msg: Str
}

Source: std/tls.xo:18

TlsErr.display

fn (e: TlsErr) display() -> Str

The message (decision 0358).

Source: std/tls.xo:23

TlsCert

struct TlsCert {}

A certificate chain with its private key (std.md 27); a handle. std/http’s TlsCert is this type (decision 0433).

Source: std/tls.xo:33

ClientAuth

enum ClientAuth {
  None
  Request
  RequireAny
  VerifyIfGiven
  RequireAndVerify
} derive Display

What a TLS server asks of a client’s certificate (Go’s tls.ClientAuthType, in Go’s order and meaning; decision 0433).

Source: std/tls.xo:41

TlsConn

struct TlsConn {}

A TLS connection (std.md 27); a handle.

Source: std/tls.xo:55

TlsConn.read

fn (t: TlsConn) read(max: Int) -> Bytes? ! NetErr uses net.dial

Source: std/tls.xo:67

TlsConn.write

fn (t: TlsConn) write(data: Bytes) -> () ! NetErr uses net.dial

Source: std/tls.xo:68

TlsConn.close

fn (t: TlsConn) close()

Source: std/tls.xo:69

TlsConn.set_deadline

fn (t: TlsConn) set_deadline(clock: Clock, at: Time?) uses clock

The connection’s deadlines (decision 0430), Go’s tls.Conn SetDeadline: a read or write past t fails with Timeout and the connection stays usable, mid-record included; they apply to the handshake too when set on the Conn before client.

Source: std/tls.xo:74

TlsConn.set_read_deadline

fn (t: TlsConn) set_read_deadline(clock: Clock, at: Time?) uses clock

Source: std/tls.xo:75

TlsConn.set_write_deadline

fn (t: TlsConn) set_write_deadline(clock: Clock, at: Time?) uses clock

Source: std/tls.xo:76

TlsConn.alpn

fn (t: TlsConn) alpn() -> Str

The protocol the server chose by ALPN, "" for none.

Source: std/tls.xo:78

TlsConn.version

fn (t: TlsConn) version() -> Str

“TLS 1.2” or “TLS 1.3”.

Source: std/tls.xo:80

TlsConn.peer_certificates

fn (t: TlsConn) peer_certificates() -> List[x509.Certificate]

The server’s certificates as it sent them, leaf first (Go’s ConnectionState.PeerCertificates); empty without TLS (FakeNet).

Source: std/tls.xo:83

Functions

roots

fn roots(pem: Bytes) -> Roots ! TlsErr

Parses the CERTIFICATE blocks of a PEM text, as http’s with_roots.

Source: std/tls.xo:26

roots_of

fn roots_of(certs: List[x509.Certificate]) -> Roots ! TlsErr

Roots of parsed certificates (std/x509), as roots does of a PEM text.

Source: std/tls.xo:29

cert

fn cert(cert_pem: Bytes, key_pem: Bytes) -> TlsCert ! TlsErr

Parses a PEM certificate chain and its PEM private key (Go’s tls.X509KeyPair), as http.tls_cert.

Source: std/tls.xo:37

client

fn client(c: Conn, host: Str, roots: Roots? = None, verify: Verify = Verify.Full, alpn: List[Str] = [], cert: TlsCert? = None, verify_conn: (fn(List[x509.Certificate]) -> () ! Str)? = None) -> TlsConn ! NetErr uses net.dial

Runs a TLS client handshake on c, which belongs to the result from then on (std.md 27). cert is the certificate presented when the server asks for one (decision 0433).

Source: std/tls.xo:60

pin_sha1

fn pin_sha1(pin: Str) -> fn(List[x509.Certificate]) -> () ! Str ! Str

A verify_conn function (also Client.with_verify_conn’s) that accepts a server whose leaf certificate’s DER has the SHA-1 digest pin (hex, colons and spaces ignored; Service Fabric’s thumbprint), compared in constant time; the text of a bad pin is the Err of the call.

Source: std/tls.xo:64

pin_sha256

fn pin_sha256(pin: Str) -> fn(List[x509.Certificate]) -> () ! Str ! Str

Like pin_sha1, over SHA-256.

Source: std/tls.xo:66

↑ index