---
name: qsafe-fix
description: Make a website's HTTPS quantum-ready. Use when the user asks to check or enable post-quantum TLS (X25519MLKEM768 / ML-KEM key exchange), fix a qsafe.sh score, harden TLS versions or HSTS, or act on a qsafe.sh report for a domain they own.
---

# qsafe-fix: make a site quantum-ready

You scan the domain with qsafe.sh, find where TLS is configured in this repository, make the
smallest change that fixes each finding, and verify after the user deploys.

## Rules

- Only work on domains the user owns or operates. Ask if unsure.
- Never deploy, restart services, run `terraform apply`, or touch production or secrets. You
  edit files on a branch and show the diff; the user ships it.
- Change only TLS and header settings the findings call for. Keep everything else as it is.
- If the fix needs something outside this repo (a CDN dashboard setting, an OpenSSL upgrade on
  the host, a provider support ticket), say so plainly with the exact steps instead of guessing.

## 1. Scan

Prefer the qsafe MCP server if it's connected (`scan_domain`). Otherwise:

```bash
curl -s "https://qsafe.sh/api/v1/scan?domain=DOMAIN"
```

Read `score`, `label`, `stack` (what terminates TLS, edge first) and `findings`. Each finding has
`id`, `severity`, `fix`, and often `snippet` and `snippet_where`. Work on findings with severity
`high`, `medium` and `low`, in that order. `pass` and `info` need nothing.

If `stack[0]` is a CDN or platform (Cloudflare, CloudFront, Fastly, Akamai, Azure Front Door,
Google Cloud, Vercel, Netlify, GitHub Pages), TLS is terminated there. Server config in the repo
won't change the key exchange; look for the CDN's infrastructure-as-code instead (see below) or
give the user the dashboard steps from the finding.

For the full guide of one stack: `get_fix` (MCP) or `curl -s https://qsafe.sh/api/v1/fixes/STACK`.

## 2. Find the config

Search the repo for where TLS is set. Typical places:

| Stack | Look for |
|---|---|
| Nginx | `nginx.conf`, `conf.d/*.conf`, `sites-*/*`, `ssl_protocols`, `ssl_ecdh_curve`, Helm values for ingress-nginx (`ssl-ecdh-curve`) |
| Apache | `httpd.conf`, `ssl.conf`, `*.conf` with `SSLEngine on` |
| HAProxy | `haproxy.cfg`, `ssl-default-bind-*` |
| Caddy | `Caddyfile`, `tls {` blocks with `curves` |
| Traefik | `traefik.yml`, dynamic config `tls.options` |
| AWS | Terraform `aws_lb_listener.ssl_policy`, `aws_cloudfront_distribution.viewer_certificate.minimum_protocol_version`, CloudFormation/CDK equivalents |
| Cloudflare | Terraform `cloudflare_zone_setting` (`min_tls_version`, `tls_1_3`, `always_use_https`) |
| Google Cloud | `google_compute_ssl_policy` |
| Azure | Front Door custom domain TLS settings in Bicep/Terraform |
| Node.js / Go | `https.createServer`, `tls.createServer` options; Go `tls.Config` |
| Containers | `Dockerfile` base images: OpenSSL 3.5+ is needed for ML-KEM with Nginx/Apache/HAProxy (Debian 13, Ubuntu 25.10+, Alpine 3.22+, Fedora 42+) |

## 3. Fix

- Use the finding's `snippet` as the target setting, adapted to the file's existing style.
- If a group list exists (`ssl_ecdh_curve`, `SSLOpenSSLConfCmd Groups`, `curves`,
  `CurvePreferences`), put `X25519MLKEM768` first and keep a classical fallback (`X25519`, P-256).
- If the server is built on OpenSSL older than 3.5, the group setting alone won't work: also
  bump the base image or package, and tell the user.
- Make one commit per logical change with a clear message, on a new branch.

## 4. Hand over and verify

Show the diff and list anything the user must do outside the repo. Ask them to deploy. After they
confirm it's live, verify:

- MCP: `verify_fix` with the domain.
- Otherwise: `curl -s "https://qsafe.sh/api/v1/scan?domain=DOMAIN&fresh=1"` and compare findings
  with the first scan.

Report the new score and which findings are fixed, still open, or new. Fresh scans are rate
limited (5 a minute, 30 a day); if you get HTTP 429, wait for `Retry-After`.
