tls
A TLS stream library for Carp, built on OpenSSL.
Provides TlsStream, an encrypted TCP stream with an API that mirrors
TcpStream. Connect to remote
hosts over TLS 1.2+, send and receive data, with system CA verification and
SNI support.
Connecting and reading
(load "tls.carp")
(defn main []
(match (TlsStream.connect "example.com" 443)
(Result.Success s)
(do
(ignore (TlsStream.send &s "GET / HTTP/1.1\r\nHost: example.com\r\nConnection: close\r\n\r\n"))
(match (the (Result String String) (TlsStream.read &s))
(Result.Success body) (println* &body)
(Result.Error e) (IO.errorln &e))
(TlsStream.close s))
(Result.Error e) (IO.errorln &e)))
Requirements
Requires OpenSSL (or LibreSSL) installed and discoverable via pkg-config.
On macOS with Homebrew: brew install openssl.