Ptls
Bun

property

WebSocketOptionsTLS.tls

tls?: TLSOptions

Options for the TLS connection.

Supports full TLS configuration including custom CA certificates, client certificates, and other TLS settings (same as fetch).

// Using BunFile for certificates
const ws = new WebSocket("wss://example.com", {
  tls: {
    ca: Bun.file("./ca.pem")
  }
});

// Using Buffer
const ws = new WebSocket("wss://example.com", {
  tls: {
    ca: fs.readFileSync("./ca.pem")
  }
});