Skip to main content

HTTPS And Mesh

The PC printer driver can expose HTTPS through Caddy and PeerJS signaling through /mesh.

HTTPS Conditions

HTTPS starts only when all of these are true:
  • features.httpsEnabled is true.
  • caddy.enabled is true.
  • The runtime platform is Windows.
  • Certificates exist in assets/certs.
  • Caddy can be installed or reused.
If HTTPS setup fails, the driver logs the error and continues with HTTP.

Certificate Files

Required files:
assets/certs/ca.crt
assets/certs/server.crt
assets/certs/server.key
The driver copies them into the Caddy working folder:
assets/caddy/ca.crt
assets/caddy/server.crt
assets/caddy/server.key
The CA certificate can be downloaded from:
http://<driver-ip>:8080/ca.crt

Caddy Install

Caddy setup uses this order:
  1. Reuse assets/caddy/bin/caddy.exe if already installed with .installed.
  2. Copy bundled caddy.exe from known local paths.
  3. Download Caddy from GitHub release URL.
The configured Caddy version defaults to 2.6.4.

Generated Caddyfile

The driver writes a Caddyfile like:
{
  auto_https disable_redirects
}

plato-printer.local {
  reverse_proxy localhost:8080

  handle /mesh/* {
    reverse_proxy localhost:8080 {
      header_up Connection {http.request.header.Connection}
      header_up Upgrade {http.request.header.Upgrade}
    }
  }

  tls "assets/caddy/server.crt" "assets/caddy/server.key"
}
If caddy.httpsPort is not 443, the site address includes the port.

Caddy Runtime

Caddy runs as a child process with:
  • XDG_DATA_HOME set to assets/caddy/data
  • XDG_CONFIG_HOME set to assets/caddy/config
  • working directory set to assets/caddy
If Caddy exits unexpectedly, the driver retries up to 5 times with a 2000ms delay.

Mesh Signaling

When features.meshEnabled is true, the driver mounts PeerJS at:
ws://<driver-host>:8080/mesh
wss://plato-printer.local/mesh
GET /mesh-status returns:
  • whether mesh is enabled
  • mesh path
  • port
  • connected peer IDs
  • peer count
Mesh is signaling only. Print jobs still use the HTTP endpoints.

Common HTTPS Problems

SymptomLikely CauseFix
Browser blocks HTTPS driver URLCA certificate not trustedInstall ca.crt on the POS device.
https://plato-printer.local does not resolveDNS/hosts missingAdd local DNS or hosts entry to driver IP.
Port 443 unavailableAnother service is using itStop the other service or change caddy.httpsPort.
HTTPS skipped on macOS/LinuxCode is Windows-onlyUse HTTP in development or test Caddy separately.
Windows 7 startup errorCaddy version not 2.6.4Set caddy.version back to 2.6.4.