Skip to content
Get started
Get started

Native TLS Encryption for bunqueue TCP & HTTP

server · tls

TLS without the reverse proxy.

Point bunqueue at a certificate and key, and all traffic between clients and the server is encrypted. No nginx or Caddy in front, one cert pair covers both the TCP and HTTP ports.

1 cert pair covers TCP and HTTP0 reverse proxies neededfail-fast startup on partial config

TLS (the encryption behind https://) is opt-in: without a cert and key the server runs in plaintext, exactly as before. Turn it on whenever clients connect over a network you don’t fully trust.

Terminal window
# CLI flags
bunqueue start --tls-cert ./cert.pem --tls-key ./key.pem
# Or environment variables
TLS_CERT_FILE=./cert.pem TLS_KEY_FILE=./key.pem bunqueue start

Or in bunqueue.config.ts:

import { defineConfig } from 'bunqueue';
export default defineConfig({
server: {
tlsCertFile: './cert.pem',
tlsKeyFile: './key.pem',
},
});

One cert pair covers both servers: TCP (:6789) and HTTP/WebSocket/SSE (:6790, which becomes https:// / wss://).

The server fails fast at startup if the cert or key file is missing, or if only one of the two is set. It never silently falls back to plaintext.

import { Queue, Worker } from 'bunqueue/client';
// Public CA (Let's Encrypt etc.): verify with system CAs
const queue = new Queue('jobs', {
connection: { host: 'queue.example.com', port: 6789, tls: true },
});
// Private CA or self-signed: trust a specific CA file
const queue2 = new Queue('jobs', {
connection: { host: '10.0.0.5', port: 6789, tls: { caFile: './ca.pem' } },
});
// Dev only: skip verification
const queue3 = new Queue('jobs', {
connection: { host: 'localhost', port: 6789, tls: { rejectUnauthorized: false } },
});

Workers accept the same TLS options as queues in every SDK (in the Bun client, under connection.tls). The wire protocol is unchanged, TLS only wraps the transport.

From the CLI:

Terminal window
bunqueue stats --host queue.example.com --tls # system CAs
bunqueue stats --tls-ca ./ca.pem # custom CA
bunqueue stats --tls-no-verify # self-signed, dev only

Self-signed certificate (dev / internal networks)

Section titled “Self-signed certificate (dev / internal networks)”

No public domain? Generate your own cert:

Terminal window
openssl req -x509 -newkey rsa:2048 -nodes -days 365 \
-keyout key.pem -out cert.pem \
-subj "/CN=localhost" \
-addext "subjectAltName=DNS:localhost,IP:127.0.0.1"

Clients then connect with the CA-file option pointing at cert.pem (caFile in TypeScript and PHP, ca_file in Python, Rust, and Elixir, CAFile in Go): the self-signed cert acts as its own CA. That keeps full verification, no verification opt-out needed.

  • Certificate verification is on by default in every SDK: the client rejects untrusted or mismatched server certs unless you explicitly opt out (rejectUnauthorized: false in TypeScript, {"verify": False} in Python, ['verifyPeer' => false] in PHP, InsecureSkipVerify: true in Go, verify: false in Elixir), encryption without authentication, dev only. Rust exposes no insecure mode at all.
  • TLS encrypts traffic but does not identify clients. Combine it with auth tokens for servers exposed beyond localhost.
  • A TLS-enabled server only accepts TLS clients; plaintext clients fail the handshake immediately (they do not hang).
  • HTTP endpoints (/health, dashboards, /ws, /events) are served over https:///wss:// when TLS is enabled.