HTTPS with your own TLS certificate
Use your own certificate for a local IP address or a private DNS name. This guide creates a self-signed root certificate authority (CA) and uses it to sign the server certificate. If your organization already has a CA, follow its process to sign the server certificate.
1. Prepare the certificates
Section titled “1. Prepare the certificates”Start with an HTTP installation on a trusted network.
This example uses port 8080 for the API and 8082 for the panel. Run the commands on the
server from your installation directory. If you installed with --dir, use that directory.
cd /opt/wonkru-mdmumask 077mkdir -p certs/ca "$HOME/wonkru-ca"
openssl genpkey -algorithm RSA -aes-256-cbc \ -pkeyopt rsa_keygen_bits:3072 -out "$HOME/wonkru-ca/root-ca.key"openssl req -x509 -new -sha256 -days 1825 \ -key "$HOME/wonkru-ca/root-ca.key" -subj '/CN=Wonkru MDM Root CA' \ -addext 'basicConstraints=critical,CA:TRUE,pathlen:0' \ -addext 'keyUsage=critical,keyCertSign,cRLSign' \ -out certs/ca/local-ca.crtList the addresses used by Android devices and browsers in the server certificate’s Subject
Alternative Name (SAN) field. Use IP: for an IP address and DNS: for a DNS name. Replace
the example addresses and remove any entries you do not use.
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out certs/tls.keyopenssl req -new -key certs/tls.key -subj '/CN=wonkru-mdm' \ -out "$HOME/wonkru-ca/server.csr"
cat > "$HOME/wonkru-ca/server.ext" <<'EOF'basicConstraints=critical,CA:FALSEkeyUsage=critical,digitalSignature,keyEnciphermentextendedKeyUsage=serverAuthsubjectAltName=IP:192.168.1.20,DNS:api.mdm.example.com,DNS:panel.mdm.example.comEOF
openssl x509 -req -sha256 -days 365 \ -in "$HOME/wonkru-ca/server.csr" \ -CA certs/ca/local-ca.crt -CAkey "$HOME/wonkru-ca/root-ca.key" \ -CAcreateserial -CAserial "$HOME/wonkru-ca/root-ca.srl" \ -extfile "$HOME/wonkru-ca/server.ext" -out certs/tls.crt
chmod 700 certs certs/cachmod 600 certs/tls.keyopenssl verify -CAfile certs/ca/local-ca.crt certs/tls.crtCaddy uses certs/tls.crt and certs/tls.key. Distribute certs/ca/local-ca.crt to
browsers and devices. Move root-ca.key to secure storage. If your organization’s CA uses
intermediate certificates, give Caddy the server certificate and intermediates in the same PEM
file, certs/tls.crt.
2. Configure Caddy and Wonkru MDM
Section titled “2. Configure Caddy and Wonkru MDM”Edit the corresponding lines in the existing .env file. This example publishes ports
8080 and 8082. If you use different published ports, use them in API_PORT, WEB_PORT,
*_PUBLIC_PORT, APP_URL, and PANEL_ORIGIN. Keep 8080 and 8082 in API_SITE
and WEB_SITE. Those are Caddy’s ports inside the container for this setup.
API_PORT=8080WEB_PORT=8082API_PUBLIC_SCHEME=httpsAPI_PUBLIC_HOST=192.168.1.20API_PUBLIC_PORT=8080WEB_PUBLIC_SCHEME=httpsWEB_PUBLIC_HOST=192.168.1.20WEB_PUBLIC_PORT=8082APP_URL=https://192.168.1.20:8080PANEL_ORIGIN=https://192.168.1.20:8082API_SITE=https://192.168.1.20:8080WEB_SITE=https://192.168.1.20:8082AUTH_COOKIE_SECURE=trueCADDY_TLS="tls /certs/tls.crt /certs/tls.key"If you use DNS, put the API name in the API settings and the panel name in the panel settings.
Both names must resolve to the server and appear in the certificate’s SAN list. For an existing
HTTPS installation on port 443, keep the current names and ports and change CADDY_TLS.
Add this configuration to docker-compose.local.yaml in the installation directory.
Wonkru MDM mounts the CA directory read-only. Caddy reads the server certificate and key from
its own mount.
services: server: environment: LOCAL_CA_PATH: /etc/wonkru-mdm/ca/local-ca.crt volumes: - ./certs/ca:/etc/wonkru-mdm/ca:ro caddy: ports: - "${HTTP_BIND_IP:-127.0.0.1}:80:8098"This port mapping opens http://192.168.1.20/downloads/local-ca. The HTTP listener serves
only the CA certificate. If Caddy already publishes host port 80, omit the caddy block above
and add CA_BOOTSTRAP_SITE=http://:80 to .env.
Use a Caddy configuration that includes the HTTP CA route and an agent APK with the SHA-256 fingerprint field.
docker compose -f docker-compose.yaml -f docker-compose.override.yaml \ -f docker-compose.local.yaml up -d --wait --force-recreate server caddy
curl -fsS http://192.168.1.20/downloads/local-ca | cmp - certs/ca/local-ca.crt
curl -fsS --cacert certs/ca/local-ca.crt \ https://192.168.1.20:8080/downloads/local-ca | cmp - certs/ca/local-ca.crtIf cmp returns without printing anything, the downloaded file matches your CA certificate.
Run the same Compose command after renewing the certificate. The update script loads
docker-compose.local.yaml. When managing services yourself, include that file with -f.
3. Prepare browsers and Android devices
Section titled “3. Prepare browsers and Android devices”- Computer running the panel. Add the root CA to the operating system or browser’s trusted root certificates. Until then, the browser shows a certificate warning. Once the CA is trusted, open the panel at the address in the certificate.
- Factory-reset Android device. Android downloads the APK from the QR code before the
Wonkru agent starts. Use an HTTPS download URL the device already trusts. You can use the signed
APK for your version from GitHub Releases.
Create a new Provisioning Profile in the panel and set
android.app.extra.PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATIONto that URL in the raw JSON. The checksum must match the APK at the download URL. Setserver_urlto the Wonkru HTTPS API address that uses your private CA. - Wonkru agent. On the first enrollment screen, select Enter CA server info. If the agent
already knows the HTTPS API address, it uses that hostname to fill in the HTTP download URL.
Edit it if needed, for example to
http://192.168.1.20/downloads/local-ca. Enter the SHA-256 fingerprint from your administrator and select Download and install certificate. The agent verifies the fingerprint before installing the certificate. Finish enrollment using the HTTPS API address.
Run the following command to get the root CA’s SHA-256 fingerprint. Send it to the person
setting up the device through a trusted channel. Paste the text after the = into the agent’s
fingerprint field. The fingerprint is optional when the CA download uses an HTTPS address
the device already trusts.
openssl x509 -in certs/ca/local-ca.crt -noout -fingerprint -sha256Use Caddy’s internal CA
Section titled “Use Caddy’s internal CA”With CADDY_TLS="tls internal", Caddy generates the server certificate and signs it with
its own root CA. Distribute Caddy’s root certificate to clients. In the ready-image Compose
installation, copy it out of the Caddy container with this command.
mkdir -p certs/cadocker compose cp caddy:/data/caddy/pki/authorities/local/root.crt certs/ca/local-ca.crtBrowsers and Android devices must trust Caddy’s root CA to connect. Caddy TLS settings · Android QR provisioning