tls reference
The tls package: tls.
tls
class Stream
offer class StreamA TLS connection over a socket.
The socket is held so that closing the stream closes both: a TLS connection whose socket outlives it is a descriptor nobody owns.
field session
var session: s64field socket
var socket: Socketfield open
var open: bool = falsemethod deinit
deinitmethod IsOpen
fun IsOpen() -> boolmethod Send
fun Send(message: text) -> bool uses unsafeSends everything in message. False when the connection broke.
method Receive
fun Receive(limit: int) -> text uses unsafeReads up to limit bytes. "" when the other end closed.
method Close
fun Close() uses unsafefunction StreamNone
offer fun StreamNone() -> StreamA closed stream, which is what a failure answers with.
function Handshake
offer fun Handshake(host: text, port: int, verify: bool) -> Stream uses net, unsafeConnects to host on port and shakes hands.
Handshake rather than Open, because a program that speaks both
HTTP and TLS imports both and this language has no import aliases
(D150).
The certificate is verified against the system's own roots, and the
name is checked against it: TLS that does not check the name is TLS
that any server can answer (D150). verify = false is for a
development server with a certificate it signed itself, and says so
at the call.