AtlatestRenderedmarkdown
Readme

sigil-tls

TLS/SSL client connections for Sigil.

Secure TCP connections using mbedTLS. Supports TLS 1.2 and TLS 1.3 client connections with system CA certificate verification, non-blocking I/O, and STARTTLS upgrades of existing sockets.

Modules

ModulePurpose
(sigil tls)TLS 1.2 and TLS 1.3 client connections

API summary

ProcedurePurpose
tls-connectOpen a TLS connection to a host/port
tls-upgradeUpgrade an existing TCP socket to TLS (STARTTLS)
tls-readRead a string from a TLS connection
tls-read-bytevectorRead raw bytes from a TLS connection
tls-writeWrite a string or bytevector to a TLS connection
tls-closeClose a TLS connection
tls-closed?Whether a connection is closed
tls-connection?Whether a value is a TLS connection
tls-set-non-blocking!Toggle non-blocking mode on the underlying socket

Connection diagnostics

tls-connect/details and tls-upgrade/details accept the same arguments as their /status counterparts and return a dictionary. The existing connection and /status APIs retain their return shapes.

status: gives the stable outcome and connection: is the connection or #f. error-code:, error-message:, and handshake-state: describe a failed handshake. protocol: and cipher: identify a successful negotiation. Details belong to that attempt and survive later connections. Handshake state names are diagnostic information; use status: for application decisions.

System prerequisites

None beyond a working C toolchain. mbedTLS is consumed transitively via sigil-crypto, which vendors mbedTLS and exposes its headers to downstream consumers automatically.

Dependencies

  • sigil-stdlib
  • sigil-crypto (vendors mbedTLS)

Build

sigil deps install
sigil build
sigil test --report

Usage

(import (sigil tls))

(let ((conn (tls-connect "example.com" 443)))
  (tls-write conn "GET / HTTP/1.1\r\nHost: example.com\r\n\r\n")
  (display (tls-read conn))
  (tls-close conn))

Set SIGIL_TLS_INSECURE=1 to skip certificate verification (testing only).

License

BSD-3-Clause. See sigil-crypto for the vendored mbedTLS license terms.