Skip to content

HTTPS settings and your own certificate

This page is the reference for how TriggerGate serves HTTPS: how its default certificate authority works, the ports, the settings, and how to use a certificate from your own organization on the Windows service, the Advantech UNO and the ESP32 board. To install the certificate on a computer or phone, see Open the web page over HTTPS.

How the default certificate authority works

With nothing configured, each installation creates its own certificate authority (CA) the first time it starts, and issues the server certificate from it.

  • Nothing is shared. Every Windows service, UNO and ESP32 board has a CA of its own. No key is in the installer, the package or the firmware image. The ESP32 boards all run the same firmware; only the keys each board generates differ.
  • The CA can vouch for one name only. It is restricted to the installation's secure name and names beneath it. A leaked key could impersonate that one service and nothing else.
  • The name is fixed when the CA is created. On the Windows service and the UNO it is <host>-triggergate.local, where <host> is the computer's name at that moment. If the computer is renamed, the old name stays in force until you reset the identity. On an ESP32 board it is triggergate-<id>.local, where <id> is the last three bytes of the board's Ethernet MAC address as six hexadecimal digits.
  • The server certificate is valid for 800 days. The Windows service and the UNO renew it by themselves at start-up and daily once fewer than 90 days remain, and browsers that trust the CA notice nothing. An ESP32 board never renews by itself, and does not use its NTP clock for certificates: it creates its CA and first certificate at its first start, before its network is up, and dates them from the firmware's build time, so the first certificate's 800 days count from the build, not from the first start. You renew it from its certificate page, which sends the time from your browser. See Renewal and reset.
  • The certificate page is at /.well-known/gameshowpro/ on the plain-HTTP port. It offers the CA certificate for each system (ca.crt for Windows and Android, ca.pem for macOS and Linux, ca.mobileconfig for iPhone and iPad) with the install steps and the CA's SHA-256 fingerprint, so that you can compare it with the one you were given. Install only that public certificate. A browser that already trusts the CA is told so and forwarded to the secure address after a short countdown.

What happens when you open the plain-HTTP address

Request Result
A browser page request for localhost, 127.0.0.1 or [::1] (Windows service and UNO) The web page, over plain HTTP. localhost counts as a secure page, so no certificate is needed on the computer that runs the service.
A browser page request from another computer Redirected once to the certificate page, which keeps the page you asked for and forwards you to it at the secure address after the trust check.
The hub (/TriggerGate), API calls, scripts, styles, images and POST requests Never redirected.

There is no plain-HTTP fallback: the web page needs a secure browser context, so from another computer it can run only over HTTPS. The web page has a Secure access and certificate link in its Service panel that opens the certificate page. If a browser reaches the HTTPS port by an address the certificate does not cover (an IP address, on a computer that cannot look up .local names), the certificate page offers Continue on this address, which stops the redirect for that browser session.

Opened on the Windows or UNO computer itself at a localhost address, the certificate page also shows the secure address (with a copy button), a QR code for the plain-HTTP setup address and the plain-HTTP address of the computer's network interface, so you can hand them to another computer or phone.

Ports and addresses

Windows service Advantech UNO ESP32 board
Plain HTTP 9090 9090 80 and 9090
HTTPS 9190 443 443
Secure address https://<host>-triggergate.local:9190/ https://<host>-triggergate.local/ https://triggergate-<id>.local/
Certificate page http://<host>-triggergate.local:9090/.well-known/gameshowpro/ the same, on the UNO's name http://triggergate-<id>.local/.well-known/gameshowpro/
  • Programs that use the TriggerGate hub, such as the .NET client library, keep using plain HTTP on port 9090 on all three. The Windows service and the UNO also answer the hub on their HTTPS port.
  • The Windows HTTPS port is the plain-HTTP port plus 100. The UNO uses 443 so that the address needs no port number.
  • The ESP32 board serves the certificate page on ports 80, 9090 and 443. Port 80 is also where its firmware updates arrive.
  • The board allows three HTTPS connections at once, because each takes a large share of its memory. Every open web page keeps one open for its live connection, so close pages you are not using.

Firewall

Allow the HTTP port, the HTTPS port and mDNS (UDP port 5353, needed for the .local name) between the computers that open the web page and the service.

  • Windows service. The Chocolatey package adds a firewall rule that allows the TriggerGate program on private network profiles. It covers all of the program's ports, including the HTTPS port. On a network classified as public or domain, add a rule yourself.
  • Advantech UNO. The installation does not change the UNO's firewall. If you run one, allow the ports above.

Settings

Setting Effect
TriggerGate:HttpsPort The HTTPS port: 9190 on the Windows service, 443 on the UNO. 0 turns HTTPS off, which leaves only the plain-HTTP port. It must differ from TriggerGate:ServicePort and TriggerGate:WebUiPort, or the service does not start. A value that is not a number or is outside 0 to 65535 also stops it.
TriggerGate:ServicePort The plain-HTTP port, which carries the hub. 9090 by default.
TriggerGate:WebUiPort An optional separate port for the web page. By default there is none and the service port serves the page. When set, the service port redirects page requests to it.
TriggerGate:TlsStorageDirectory Where the CA and certificate are kept. See Where the keys are kept.
TriggerGate:CertificatePath A certificate file to serve instead of the CA's. See Use your own certificate.
TriggerGate:CertificateKeyPath The private key file, when the certificate is a PEM file and the key is in another file.
TriggerGate:CertificatePassword The password of a PFX file or of an encrypted key file.

Blank values are ignored. Set them in the TriggerGate section of the service's appsettings.json (see Install on Windows), as command-line arguments (--TriggerGate:HttpsPort=0) or as environment variables (TriggerGate__HttpsPort=0); command-line arguments and environment variables take precedence over appsettings.json. appsettings.json belongs to the package, so keep a note of what you change there. On the UNO, the service reads environment variables from /etc/default/triggergate; restart the service after changing it with sudo systemctl restart triggergate.service. The ESP32 board has no settings for HTTPS: it always serves HTTPS on port 443, and takes a certificate of your own by upload (see Your own certificate on the ESP32 board).

Use your own certificate

If your organization has a certificate authority that its computers and phones already trust, or you have a certificate from a public authority, TriggerGate can serve that certificate instead of the one from its own CA. Computers and phones that trust the issuer then need nothing installed.

On the Windows service and the UNO, from highest to lowest priority, TriggerGate serves:

  1. Nothing over HTTPS, when TriggerGate:HttpsPort is 0.
  2. The certificate named by TriggerGate:CertificatePath. If Kestrel is also given a certificate, a warning is logged and each is served as configured.
  3. A certificate configured through Kestrel (see A certificate set through Kestrel).
  4. The certificate from the installation's own CA.

On the ESP32 board, a certificate you uploaded takes precedence over the certificate from the board's own CA.

In every case the own CA is kept while your certificate is in use, so removing yours returns you to the CA that computers and phones already trust.

Set TriggerGate:CertificatePath to a PFX file, or to a PEM file that holds the server certificate followed by any intermediate certificates. Add TriggerGate:CertificateKeyPath when the key is a separate PEM file, and TriggerGate:CertificatePassword when the PFX or the key is protected by a password. The service account must be able to read the files. The Chocolatey service runs as NT AUTHORITY\LocalService.

  • The address is the name in your certificate, on the same HTTPS port (9190 by default). Your network's DNS must lead that name to the computer. The .local secure address is not used.
  • Plain-HTTP page requests from another computer to a name your certificate covers are redirected to HTTPS. Other names, IP addresses and localhost stay on plain HTTP.
  • Intermediate certificates must be installed. Windows sends only the certificates it finds in its own stores, and TriggerGate adds nothing to them. If your certificate was issued through an intermediate authority, install that authority's certificate in Intermediate Certification Authorities on the TriggerGate computer (Manage computer certificates), or use a certificate issued directly by a root the clients trust.
  • TriggerGate checks the files every two seconds and starts using a replaced certificate without a restart. It logs a warning daily from 30 days before the certificate expires. Renewal is yours.
  • A certificate that cannot be loaded stops HTTPS until the files are corrected. TriggerGate does not fall back to its own CA, which would silently change what browsers must trust. The service log says what is wrong.
  • There are no CA downloads, Renew certificate or Reset identity in this mode, and the secure name is not advertised.

To return to the own CA, remove the settings and restart the service.

Set TriggerGate:CertificatePath (and the key and password settings, as for the Windows service) in /etc/default/triggergate, for example:

TriggerGate__CertificatePath=/etc/triggergate/tls/server.pfx
# TriggerGate__CertificatePassword=<PFX password>

Keep the file outside the installation folder and make it readable by root, which the service runs as: owner root, mode 0600. Upgrades do not touch /etc/default/triggergate, and the certificate and key are never part of the package. Restart with sudo systemctl restart triggergate.service and check sudo systemctl status triggergate.service.

  • The address is the name in your certificate, on port 443. Your network's DNS must lead that name to the UNO.
  • Plain-HTTP page requests from another computer to a name your certificate covers are redirected to HTTPS. Other names, IP addresses and localhost stay on plain HTTP.
  • On Linux the intermediate certificates in the file are sent.
  • TriggerGate checks the files every two seconds and uses a replaced certificate without a restart. It logs a warning daily from 30 days before expiry. Renewal is yours.
  • A certificate that cannot be loaded stops HTTPS until the files are corrected; TriggerGate does not fall back to its own CA.
  • There are no CA downloads, Renew certificate or Reset identity in this mode.

To return to the own CA, remove the settings and restart the service.

A board takes a certificate by upload to its certificate page, not by settings. You can have the board create a signing request for your CA to sign (the key never leaves the board), or upload a certificate chain with its key. See Your own certificate on the ESP32 board.

A certificate set through Kestrel (Windows service and UNO)

A certificate configured in Kestrel, the web server inside TriggerGate, is also accepted. It applies when any Kestrel:Endpoints entry has an https URL, or Kestrel:Certificates:Default:Path is set, and TriggerGate:CertificatePath is not. Prefer TriggerGate:CertificatePath, which reloads a replaced file by itself.

  • No CA is created, and TriggerGate:HttpsPort is ignored.
  • A plain-HTTP request for the root page, from any host including the computer itself, is redirected to the HTTPS address.
  • Use a PFX file with the server certificate and its private key. Its names must include the DNS name or IP address used in the browser. An IP address stops matching when DHCP assigns a different one, so reserve addresses or use a stable name.
  • Kestrel:Endpoints with only http URLs do not count: the own CA still starts and adds its HTTPS listener next to them.
  • Once Kestrel:Endpoints is configured, those endpoints replace TriggerGate's default listeners. Include the HTTP endpoint on the service port explicitly to keep port 9090 for the hub.

A default certificate on its own does not open an HTTPS port; define an https endpoint as well. As environment variables for the service:

Kestrel__Endpoints__Http__Url=http://0.0.0.0:9090
Kestrel__Endpoints__Https__Url=https://0.0.0.0:9190
Kestrel__Endpoints__Https__Certificate__Path=C:\certs\triggergate.pfx
Kestrel__Endpoints__Https__Certificate__Password=<PFX password>

Leave out the password line when the PFX has none. Give the service account read access to the file, and allow the HTTPS port through the firewall.

Set the default certificate in /etc/default/triggergate; HTTPS is then bound on port 443:

Kestrel__Certificates__Default__Path=/etc/triggergate/tls/server.pfx
# Kestrel__Certificates__Default__Password=<PFX password>

If you define Kestrel:Endpoints instead, the UNO requires both an HTTP endpoint on the service port (and on TriggerGate:WebUiPort, if set) and an HTTPS endpoint with its certificate. Otherwise the service does not start. The HTTPS port may differ from 443; the redirect from the HTTP root follows it.

Your own certificate on the ESP32 board

By default a board serves a certificate from its own CA. If your site has a CA that its computers and phones trust, you can give the board a certificate from it. There are two ways:

  • Signing request (recommended). The board creates a key and a certificate signing request. Your CA signs the request and you upload only the signed certificate. The key never leaves the board, so this also works over plain HTTP. The request's key is EC P-256, which the board sets up faster than an uploaded RSA key.
  • Certificate and key. You upload a certificate chain and its private key. This is accepted over HTTPS only.

The board's certificate page (/.well-known/gameshowpro/, over HTTP or HTTPS) has a Your own certificate section. It shows which certificate is served, its names and its expiry, and offers these actions: upload a certificate and key (HTTPS only), create a signing request and download it, upload the signed certificate, and remove your certificate. After a change made over HTTPS, the board restarts its HTTPS server, so the page may stop responding for a moment: reload it. The sections below describe the same steps for scripts and curl.

When you can make changes: the boot window

Uploading, creating a signing request and removing are accepted only for five minutes after the board powers up, the same window as Renew and Reset. Power-cycle the board (or its PoE port) to open it. A software restart, such as a firmware update, does not open it. The page counts down the remaining time and disables the buttons for these actions when the window closes.

Each request must have Content-Type: application/json (415 otherwise). Its Host must be the board's .local name, its bare name or an IP address, and an Origin, if sent, must match the Host. The body carries "time", the current time in Unix seconds, because the board does not use its NTP clock for certificates; it takes this time to check that the certificate is valid now, and refuses a time earlier than its firmware's build. The page sends it from the browser's clock, so the computer or phone you use must have the right date and time.

A refused request (403) answers with JSON, {"error": "...", "reason": "<code>"}. The code names the first check that failed, in this order: host, origin, gate-closed (the window is closed). info.json carries gateSecondsRemaining, the whole seconds left in the window (0 when it is closed).

Signing request

  1. Within the window, ask the board for a request:

    curl -s -X POST -H 'Content-Type: application/json' -d "{\"time\":$(date +%s)}" \
      http://triggergate-<id>.local/.well-known/gameshowpro/certificate/request > board.csr
    

    The response is a PKCS#10 request as PEM: an EC P-256 key, subject CN=<name>.local and a subject alternative name for <name>.local. A new request replaces any earlier one. You can fetch the pending request again at any time, without the window, from GET /.well-known/gameshowpro/certificate/request.csr (404 when none is pending).

  2. Have your CA sign it. Add any other DNS names your policy needs, and keep <name>.local if clients will use it. With OpenSSL, for example:

    openssl x509 -req -in board.csr -CA site-ca.pem -CAkey site-ca.key -days 397 -copy_extensions copy -out board.pem
    
  3. Within a window, upload the signed certificate, followed by your intermediate if your CA has one, and no key:

    python3 -c 'import json,sys,time; print(json.dumps({"time": int(time.time()), "certificate": open(sys.argv[1]).read()}))' board.pem \
      | curl -s -X POST -H 'Content-Type: application/json' --data-binary @- \
        http://triggergate-<id>.local/.well-known/gameshowpro/certificate
    

    The board accepts it only if the certificate holds the pending request's key. The request is then used up.

Certificate and key

Send the chain and the key in one request over HTTPS:

{"time": 1795500000, "certificate": "-----BEGIN CERTIFICATE-----\n...", "key": "-----BEGIN PRIVATE KEY-----\n..."}

to POST https://<board>/.well-known/gameshowpro/certificate. Over plain HTTP, a body that names a key member is refused before it is parsed and the received bytes are discarded; the key has still crossed the network unencrypted, so treat it as exposed. Until your CA is trusted on the computer you upload from, the board still serves a certificate from its own CA: install that CA first and compare its fingerprint with the one you were given before you send a key.

What the board accepts

  • PEM only (no PFX): one to three CERTIFICATE blocks, the server certificate first and then each issuer in order. The private key must be unencrypted, as PRIVATE KEY, EC PRIVATE KEY or RSA PRIVATE KEY.
  • Key type: EC P-256, EC P-384 or RSA 2048. Larger RSA keys are refused because of their handshake cost on the chip.
  • The server certificate must be valid at the time you send, and the key must belong to it.
  • At most 6 KiB is stored (certificates and key together), and request bodies are limited to 12 KiB.
  • Every certificate must be readable by the board's TLS library. A chain it cannot read, for example one with an unsupported critical extension such as name constraints in an intermediate, is refused rather than stored.
  • The board speaks TLS 1.2 only, with forward-secret key exchange (ECDHE) and AES-GCM. Very old browsers that need anything else are not supported.

A refused upload answers 400 with {"error": "..."} naming the failed check. Nothing is stored and the board keeps serving what it served before. A successful upload answers 200 with the new info.json, and the HTTPS server restarts with the new certificate about a second later. If the board is short of memory, for example during a page load, it answers 503; try again a few seconds later.

Remove your certificate

curl -s -X POST -H 'Content-Type: application/json' -d "{\"time\":$(date +%s)}" \
  http://triggergate-<id>.local/.well-known/gameshowpro/certificate/remove

This deletes your certificate and any pending request. The board serves a certificate from its own CA again.

What to expect

  • Renew and Reset keep acting on the board's own CA, not on your certificate. The board never renews your certificate: watch its expiry on the certificate page.
  • Your certificate and key are stored with the board's CA in its flash memory, which is not encrypted.
  • If the stored certificate cannot be used when the board starts (damaged, for example), the board serves a certificate from its own CA instead, so a bad upload cannot lock you out. Remove it, or upload another.
  • info.json reports certificateSource ("ca" or "own"), and, for your own certificate, certificateNotAfter, certificateDnsNames and certificateRequestPending.

Where the keys are kept

The folder or storage that holds the CA and certificate holds private keys. Do not copy it into a backup, an archive or a shared drive. If it is lost, TriggerGate creates a new CA at the next start, and every computer and phone must install the new certificate, as after a reset.

%ProgramData%\GameshowPro\TriggerGate\tls, unless TriggerGate:TlsStorageDirectory names another folder. The folder is limited to the service account, SYSTEM and administrators, and the private keys in it are encrypted with Windows data protection (machine scope). If the service is changed to run as another account, that account may not be able to open the folder; HTTPS then stops until you reset the identity.

/var/lib/gameshowpro/triggergate/tls, unless TriggerGate:TlsStorageDirectory names another folder. Only root can open the folder (mode 0700; files 0600), and the keys are not encrypted. An upgrade does not touch the folder, so the CA survives upgrades.

In the board's own flash memory, not in a folder you can reach. The flash is not encrypted, so anyone who can take the board and read its memory can get its keys. That would let them impersonate this one board and nothing else, because of the name restriction. Erasing the flash, including a full erase when the board is flashed, also erases the keys. The board then creates a new CA at its next start, and every computer and phone must install the new certificate.

When the stored identity cannot be read

TriggerGate never replaces an identity it cannot read. The service keeps running and plain HTTP keeps working, and the certificate page is served, but HTTPS connections fail and the CA downloads and info.json answer 503. Use Reset identity, which creates a new CA, and install the new certificate everywhere. On the Windows service, use the page opened on the computer itself; on the UNO, use an SSH tunnel; on an ESP32 board, power-cycle it and reset within five minutes. See Renewal and reset and If it does not work.

Discovery names

The certificate covers one name, so the name matters when you look for the service on the network.

  • Windows service and UNO. With the own CA, the service advertises its secure name, <host>-triggergate.local, with its HTTPS and HTTP ports over mDNS. If another device answers for the same name, the secure address may open the wrong device. See Renewal and reset. With your own certificate, the secure name is not advertised and the address is the name in your certificate.
  • All three. The hub is advertised as _gp-triggergate._tcp on port 9090, which is how the .NET client finds it. This does not depend on the certificate.
  • ESP32 board. The board's mDNS host name is its secure name, triggergate-<id>.local, and the service instance uses the same name without .local. Besides the hub, it advertises _https._tcp on port 443 and _http._tcp on port 80 with the path /.well-known/gameshowpro/. If another device answers for the same name, the board is renamed by its network stack (to <name>-2.local), which it cannot prevent. It reports nameConflict: true, and the certificate stays valid only for the original name. If the board's derived name would later differ from the stored one, the stored one stays in force and info.json reports nameMismatch; only a reset adopts the new name.
v2.0.62