New — Iris AI drafts your firewall, routing & rate-limit rules. Explore AI features →
Back to Blog
security

mTLS without running your own certificate authority

Open an internal tool only on your team's devices: create a certificate authority in ngris, give each device a certificate, require it and revoke a lost one.

7 min read
mTLS without running your own certificate authority

A password says who is signing in. It doesn't say what they're signing in from: a phished password works just as well on someone else's laptop. Mutual TLS adds the device. Each device holds a certificate, and the endpoint refuses the connection during the TLS handshake when the device can't show one, before any request reaches your app.

What kept most teams away was the certificate authority behind it: a private key to guard, OpenSSL commands for every certificate, and a list of revoked ones to keep up to date. ngris can be that authority. This guide sets it up from start to finish with one example: Acme Labs' internal Grafana at grafana.labs.example.com, which should open only on the team's laptops and phones. Above is where it ends up: one certificate per device, and the stolen laptop's revoked.

Before you start

  • An HTTPS endpoint. Mutual TLS works on HTTP(S) endpoints, for HTTP/1.1, HTTP/2 and HTTP/3 alike. TCP and UDP tunnels pass their traffic through as it is, so no client certificate is checked on them.
  • A device to test from. A laptop with curl and openssl is enough.

1. Create the certificate authority

In the dashboard, open Security → mTLS and click Create certificate authority. It asks for one thing, a name: call it after the devices it covers.

The Create certificate authority dialog with the name Company laptops
Acme's authority is Company laptops. The hint says the rest: one authority per group of devices, attached to endpoints like any other CA.

ngris makes the authority's key and keeps it. The key never leaves ngris and can't be exported, so there is no key file for you to guard. The authority is listed with your other CAs, marked Managed by ngris, and you can download its certificate if something outside ngris should trust it too.

2. Give each device a certificate

Open the Client certificates tab, pick the authority and click New certificate. Give the device a name (letters, digits, dots, dashes or underscores) and a lifetime: 90 days unless you choose another, up to 397.

The New certificate dialog from Company laptops: device name laptop-priya, lifetime 90 days, Download for a browser or phone selected, and I have a signing request (CSR)
Priya's new laptop gets laptop-priya. The certificate names the device: its subject is CN=laptop-priya.

Then choose how the device gets it:

  • Download for a browser or phone. You get a certificate file, laptop-priya.p12, and its password. The password is shown once: save it, then open the file on the device and enter the password.
  • I have a signing request (CSR). The device makes its own key and sends only a signing request, so the key never leaves the device. Paste the request and download laptop-priya.crt.

On a laptop, OpenSSL makes the key and the signing request in one line:

bash
openssl req -new -newkey ec -pkeyopt ec_paramgen_curve:P-256 -nodes \
  -keyout laptop-priya.key -subj "/CN=laptop-priya" -out laptop-priya.csr

ngris accepts ECDSA P-256 and P-384 keys, RSA keys of 2048 to 4096 bits, and Ed25519 keys.

From the command line, one command on the device does both: it makes the key there, sends only the signing request, and writes laptop-priya.crt, laptop-priya.key and ca.pem.

bash
ngris client-cert request --ca "Company laptops" --name laptop-priya

3. Require the certificate on the endpoint

Open the endpoint's Endpoint Settings → Mutual TLS tab. Under Trusted client CAs, click Add Client CA and pick the authority. Set Enforcement mode to Required and click Save changes in the bar that appears. The change applies on its own, without restarting anything.

The Mutual TLS tab of grafana.labs.example.com: enforcement mode Required, and Company laptops, managed by ngris, as the trusted client CA
Grafana trusts Company laptops and nothing else. Every certificate the authority issues gets in; nothing else gets past the handshake.

Optional asks for a certificate and lets the connection through either way, so your traffic rules can tell the two apart. It's a gentle first step while devices are still getting their certificates.

4. Check it from a device

bash
# With the certificate, the request reaches Grafana
curl --cert laptop-priya.crt --key laptop-priya.key https://grafana.labs.example.com/api/health

# Without it, the TLS handshake is refused: no request is ever made
curl https://grafana.labs.example.com/api/health

A browser with the certificate installed offers it when the site asks for one. Most browsers ask you to pick it the first time.

5. Know which device is calling

Every request that gets through tells your app which certificate the device presented. The edge removes any copies of these headers a client sends, on every endpoint, so they can only come from ngris:

Header Value
X-Client-Cert-Name The device name: laptop-priya
X-Client-Cert-Subject The certificate's subject: CN=laptop-priya
X-Client-Cert-Serial Its serial number, lowercase hex
X-Client-Cert-Fingerprint Its SHA-256 fingerprint, lowercase hex

The same details come signed in X-Ngris-Signature, a token your app can verify with the keys ngris publishes:

js
import { createRemoteJWKSet, jwtVerify } from 'jose';

const JWKS = createRemoteJWKSet(
  new URL('https://api.ngris.com/.well-known/ngris-edge-jwks.json'));

export async function ngrisDevice(req) {
  const { payload } = await jwtVerify(req.headers['x-ngris-signature'], JWKS, {
    issuer: 'https://api.ngris.com/edge-identity',
    audience: process.env.NGRIS_ENDPOINT_UUID,
    algorithms: ['ES256'],
  });
  return payload.client_cert; // { name, subject, serial, fingerprint }
}

Check that the audience is your endpoint's UUID, then decide on the certificate, never on the token's host: on HTTP/1.1 the client chooses the host. When the endpoint also signs people in, the same token says who the person is and which device they're on.

6. Different devices for different places

Endpoints trust authorities, not single certificates: every certificate an authority issues gets into every endpoint that trusts it. To keep groups of devices apart, give each group its own authority. Acme's checkout terminals and warehouse scanners have theirs, Acme field devices, and only the orders API trusts it.

Inside one endpoint, a Require Client Certificate rule narrows it further. On Grafana's Traffic Policy tab, Acme adds one to on_http_request with the condition req.path.startsWith("/admin") and Match Subject CN set to ^laptop-(maya|jonas)$. Only those two laptops reach Grafana's admin pages; any other certificate gets a 403 there.

7. When a device is lost

Find its certificate on the Client certificates tab, open its menu and choose Revoke, with a reason if you like: the reason stays on the row, as Laptop stolen does on Tomás's. Every endpoint refuses the certificate from the device's next request or connection. A WebSocket or other stream that is already open stays open until it closes.

Revoking can't be undone. If the laptop turns up, give it a new certificate.

8. Renew before a certificate expires

Issue a new certificate with the same name before the old one expires. The old one keeps working until it expires or you revoke it, so the device can switch over whenever it's ready. With the command line, write the new one to a folder of its own with --out-dir.

From your AI assistant

The ngris API and MCP server issue certificates from a signing request too. An assistant can give a new device its certificate without ever seeing the device's key.

If something doesn't work

  • The handshake fails. The device presented no certificate, or one that the endpoint's trusted authorities didn't issue. openssl s_client -connect grafana.labs.example.com:443 -cert laptop-priya.crt -key laptop-priya.key shows what the device sends and what the endpoint answers.
  • A certificate that worked yesterday. It may have expired or been revoked: its row on the Client certificates tab says which. Give the device a new one.
  • A 403 on some paths only. A Require Client Certificate rule matches there and the device's name doesn't fit it.

Get started

  1. Open Security → mTLS and click Create certificate authority.
  2. On the Client certificates tab, click New certificate for each device.
  3. On the endpoint's Mutual TLS tab, add the authority under Trusted client CAs, choose Required and save.
  4. Test with curl, with and without the certificate.
  5. Read the device in your app from X-Client-Cert-Name, or verify X-Ngris-Signature.
  6. Revoke a lost device's certificate; issue a new one before an old one expires.

Read more in the docs: Let ngris issue the certificates, Which device is calling and The signed token.

Read the docs

Ask an AI to summarise this page
Deploy
App hosting Edge functions Domains & certificates
Connect
Secure tunnels API gateway Multi-region edge
Protect
Bot protection & challenge WAF & firewall Edge login
Observe & AI
Monitoring Inspector & replay Iris AI MCP server AI Gateway
Developers
Developer tools Docs ngrok policy converter Blog Changelog
Compare
Ngris vs ngrok Ngris vs Cloudflare Tunnel Ngris vs Vercel Ngris vs Netlify Expose localhost guide
More
Solutions Pricing Enterprise Sign in Get Started Free