Skip to content

HTTPS Certificates for Bastion Desktops

This page explains how to serve a desktop's web service through the bastion with a valid HTTPS certificate from Let's Encrypt. The certificate is renewed automatically, without opening any ports and without relying on network filters between the certificate authority and the installation.

graph LR
  b(Browser):::dt -- app.example.com --> bs([IsardVDI Bastion]):::dk -- TLS untouched --> d(Desktop with certificate):::dt
  d -. publishes the challenge .-> a(acme-dns server):::dt
  le(Let's Encrypt):::dt -. DNS query .-> a
  classDef dk fill:#ffd1dc,stroke:#ff3465,stroke-width:1px

The bastion does not decrypt HTTPS traffic: it passes it directly to the desktop. Therefore, the certificate belongs to the desktop, and the desktop must obtain it.

Why the usual method fails

Most tutorials (certbot --nginx, acme.sh --standalone, Caddy's automatic HTTPS) use the HTTP-01 challenge. In this method, Let's Encrypt connects to port 80 of the name from various points around the world. Through the bastion, this process fails for two reasons:

  • The bastion names are not the user's. Addresses like <identifier>.<identifier>.bastion.example.com belong to the installation's domain.
  • Validation connections may be blocked. Installations that filter by country or IP reputation, as well as the web filters of many networks, discard some validation attempts. Let's Encrypt validates from several points simultaneously, and issuance fails intermittently, often with the error Timeout during connect (likely firewall problem).

The DNS-01 challenge avoids these two problems. The certificate authority only reads a DNS record, and the desktop only makes outbound connections. This method requires your own domain and an acme-dns server where the desktop publishes the challenge.

Which acme-dns server

If the installation has its own acme-dns server, use that one; the administration knows. If it has none, you must deploy your own. The examples on this page use the example name acme-dns.example.com.

Requirements

  • A desktop with the bastion enabled, the Enable HTTP / HTTPS access option turned on (in the old interface, HTTP) and permission for Custom domains. The bastion and custom domain permissions are granted by the administration in Bastion.
  • The desktop must have an HTTPS Internet connection (to the acme-dns server and to acme-v02.api.letsencrypt.org).
  • A web server on the desktop listening on the HTTP and HTTPS ports configured in the bastion.
  • A domain where CNAME records can be created. See «Selecting a domain».

The examples use these values, which must be replaced with the real ones:

Value Example
Name to publish app.example.dedyn.io
Desktop bastion ID c64a159b-52f2-4ebd-a226-d2bd53cf9b5f
Bastion domain of the installation bastion.example.com

1. Register an acme-dns account

From the desktop:

curl -s -X POST https://acme-dns.example.com/register | tee ~/acme-dns-compte.json
chmod 600 ~/acme-dns-compte.json

The response contains username, password, subdomain and fulldomain. Save it: the password cannot be recovered.

  • Register one account for each name to be certified.
  • Do not restrict the account with allowfrom: the outgoing IP of a desktop may change when it starts on a different server, and renewals would fail.

2. Create the two DNS records

At the DNS provider, add these records:

Name Type Value
app CNAME c64a159b-52f2-4ebd-a226-d2bd53cf9b5f.bastion.example.com.
_acme-challenge.app CNAME <subdomain>.acme-dns.example.com.

The first record redirects traffic to the bastion. The second delegates the challenge validation to the acme-dns account. Before continuing, check that the records are correct:

dig +short CNAME app.example.dedyn.io
dig +short CNAME _acme-challenge.app.example.dedyn.io

3. Add the domain to the desktop

  1. In the desktop's bastion section, add app.example.dedyn.io to the custom domains.
  2. In the old interface, click the button to verify the domain's DNS (shield icon). In the new one, the verification is done automatically on saving.
  3. Save the changes.

See the «Custom domains» section of Bastion.

4. Issue the certificate

As root on the desktop, install Acme.sh:

curl https://get.acme.sh | sh -s email=correu@example.com
source ~/.bashrc

Load the account and run a test against the Let's Encrypt staging environment, which does not count towards the limits:

export ACMEDNS_BASE_URL="https://acme-dns.example.com"
export ACMEDNS_USERNAME="$(jq -r .username  ~/acme-dns-compte.json)"
export ACMEDNS_PASSWORD="$(jq -r .password  ~/acme-dns-compte.json)"
export ACMEDNS_SUBDOMAIN="$(jq -r .subdomain ~/acme-dns-compte.json)"

acme.sh --issue --dns dns_acmedns -d app.example.dedyn.io --server letsencrypt_test

If it ends with Cert success., issue the final certificate and install it where the web server reads it:

acme.sh --issue --dns dns_acmedns -d app.example.dedyn.io --server letsencrypt --force

mkdir -p /etc/ssl/app
acme.sh --install-cert -d app.example.dedyn.io --ecc \
  --key-file       /etc/ssl/app/privkey.pem \
  --fullchain-file /etc/ssl/app/fullchain.pem \
  --reloadcmd      "systemctl reload nginx"

Tip

Acme.sh saves the account with the domain, and renewals no longer need the variables. If the issuance hangs while checking DNS, you can add --dnssleep 90 to wait instead of checking.

5. Configure the web server

server {
    listen 80;
    server_name app.example.dedyn.io;
    return 301 https://$host$request_uri;
}
server {
    listen 443 ssl;
    server_name app.example.dedyn.io;
    ssl_certificate     /etc/ssl/app/fullchain.pem;
    ssl_certificate_key /etc/ssl/app/privkey.pem;
    location / {
        proxy_pass http://127.0.0.1:3000;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-Proto https;
    }
}
<VirtualHost *:443>
    ServerName app.example.dedyn.io
    SSLEngine on
    SSLCertificateFile    /etc/ssl/app/fullchain.pem
    SSLCertificateKeyFile /etc/ssl/app/privkey.pem
    ProxyPass        / http://127.0.0.1:3000/
    ProxyPassReverse / http://127.0.0.1:3000/
</VirtualHost>

Enable the modules with a2enmod ssl proxy proxy_http and use --reloadcmd "systemctl reload apache2" when installing the certificate.

app.example.dedyn.io {
    tls /etc/ssl/app/fullchain.pem /etc/ssl/app/privkey.pem
    reverse_proxy 127.0.0.1:3000
}

The tls line prevents Caddy from trying to obtain the certificate via HTTP-01 on its own. Use --reloadcmd "systemctl reload caddy" when installing the certificate.

Traefik includes an acme-dns client and handles the whole process. The first time, it registers an account and stops, indicating which _acme-challenge CNAME must be created; once it is created and the container restarted, it issues the certificate.

services:
  traefik:
    image: traefik:v3
    command:
      - --entrypoints.web.address=:80
      - --entrypoints.websecure.address=:443
      - --providers.docker=true
      - --providers.docker.exposedbydefault=false
      - --certificatesresolvers.acmedns.acme.email=correu@example.com
      - --certificatesresolvers.acmedns.acme.storage=/letsencrypt/acme.json
      - --certificatesresolvers.acmedns.acme.dnschallenge.provider=acme-dns
    environment:
      ACME_DNS_API_BASE: https://acme-dns.example.com
      ACME_DNS_STORAGE_PATH: /letsencrypt/acme-dns-accounts.json
    ports: ["80:80", "443:443"]
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ./letsencrypt:/letsencrypt
  app:
    image: nginxdemos/hello
    labels:
      - traefik.enable=true
      - traefik.http.routers.app.rule=Host(`app.example.dedyn.io`)
      - traefik.http.routers.app.entrypoints=websecure
      - traefik.http.routers.app.tls.certresolver=acmedns

Check it from any computer:

echo | openssl s_client -connect app.example.dedyn.io:443 -servername app.example.dedyn.io 2>/dev/null \
  | openssl x509 -noout -subject -issuer -enddate

Renewal

Acme.sh installs a scheduled task that renews the certificate about 30 days before it expires and runs the --reloadcmd. The desktop must be started at some point during these 30 days.

acme.sh --list
acme.sh --renew -d app.example.dedyn.io --ecc --force --server letsencrypt_test   # dry run

Selecting a domain

For the service to work with the bastion, the domain provider must allow creating a CNAME record on the name (the bastion's verification method) and creating or delegating _acme-challenge. It is advisable for the domain to be on the Public Suffix List, so that the Let's Encrypt limits apply to the organization and not to all the users of the shared service.

Service What it offers With the bastion
A subdomain of the organization Whatever the IT team delegates Recommended
deSEC (dedyn.io) Free, one name per account, all record types Recommended free option
A domain from the GitHub Student Developer Pack A real domain, free for the first year Works
eu.org Free real domain; approval can take weeks and requires a DNS service Works
Dynu Free name with CNAME and TXT records Should work, untested
FreeDNS (afraid.org) Names under shared domains Unreliable: shared Let's Encrypt limits
DuckDNS Only A/AAAA records and one TXT Does not work: without CNAME, it fails bastion verification
nip.io, sslip.io, traefik.me IP in the name; no records can be created Does not work
Tunnels (Cloudflare Quick Tunnel, ngrok…) A provider name, bypassing the bastion Only for demonstrations.

Tunnels do not go through the bastion or IsardVDI protections. Many network filters block them, and free versions have usage limits. They are only suitable for one-off demonstrations, not for a service that needs to last.

Troubleshooting

What you see What it means What to do
Timeout during connect (likely firewall problem) HTTP-01 access is blocked Use --dns dns_acmedns as indicated in step 4.
No TXT record found at _acme-challenge… The _acme-challenge CNAME record does not exist, is wrong or has not propagated yet Check it with dig and try again in a few minutes.
The bastion says the DNS record does not exist or does not match The CNAME of the name does not point exactly to <bastion ID>.<bastion domain> Copy the bastion ID with all its hyphens.
401 from the acme-dns server The account credentials are wrong or the allowfrom parameter does not match Check the account file or create a new one without allowfrom.
429 when registering the account Too many registrations were made from the same network in the last hour Wait and try again later.
The browser shows a certificate for another name The bastion does not recognize the domain or HTTP access is not enabled Check step 3; if everything is correct, tell the administration.
CAA record … prevents issuance The domain has a CAA record that does not include Let's Encrypt Add 0 issue "letsencrypt.org".

Best practices

The account file and ~/.acme.sh must be readable only by the root user. Use one account per name and run all tests with --server letsencrypt_test. The private key never leaves the desktop.

States and messages

New-interface texts related to custom domains and bastion keys:

What you see What it means What to do
«No custom domains added» The desktop does not have its own domain yet. Click Add custom domain.
«You can use your own domain name to access this desktop via bastion.» Notice shown with More details, with the address the CNAME must point to. Create the CNAME at the DNS provider.
«Custom domain updated successfully» The domain has been saved. —
«Invalid SSH public key on line N.» A line of Authorized SSH Keys (one per line) or Other people's SSH keys (one per line) is not a valid public key. Fix the indicated line.

Permissions to manage the domain and keys

Any user with the bastion permission can enable the bastion and the protocols on their desktops; adding custom domains also requires the custom domains permission. Both permissions are granted by the administration in Bastion. Without permission, the bastion options do not appear.

Error states when loading data

If the bastion access data cannot be loaded, these messages appear. The last two appear in the window that the owner or co-owner of a deployment opens from each user's row.

What is shown What it means What to do
«Could not load bastion access» There has been a general problem loading the access data. —
«Error loading bastion data» The specific bastion data could not be retrieved. —
«Error loading user config» The configuration associated with the user could not be loaded. —
«Could not load the user's desktops» In the Bastion access for … window of a deployment view, the list of the selected user's desktops could not be retrieved. Close the window or try again later.
«This user has no desktops in this deployment» The selected user has no desktop in the deployment. Close the window.