# Post-Quantum Cryptography

API7 Enterprise `3.10.9` and later support hybrid post-quantum key exchange (`X25519MLKEM768`) for TLS 1.3 connections by default. Combining classical `X25519` with NIST FIPS 203 `ML-KEM-768` protects API traffic against Harvest-Now, Decrypt-Later (HNDL) attacks while preserving automatic fallback for classical clients and upstreams.

For a cross-product comparison across API7 Enterprise, Apache APISIX, and AISIX AI Gateway, see the [Post-Quantum Cryptography (PQC) Overview](https://docs.api7.ai/post-quantum-cryptography.md).

## Version Requirements[​](#version-requirements "Direct link to Version Requirements")

| API7 Enterprise Release | Data Plane Runtime                      | Control Plane TLS Stack    | Default PQC Status                                                                                                                          |
| ----------------------- | --------------------------------------- | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| **`3.10.9` and later**  | `apisix-runtime` with OpenSSL `3.5.9`   | Go `crypto/tls` (Go 1.24+) | **Enabled by default** (`X25519MLKEM768` on TLS 1.3)                                                                                        |
| **`3.10.0` – `3.10.8`** | OpenResty `1.29` / OpenSSL `3.4`        | Go `crypto/tls`            | Not available on the Data Plane; upgrade to `3.10.9` or later                                                                               |
| **`3.9.x` and earlier** | Legacy `api7ee-runtime` (OpenSSL `3.2`) | Go `crypto/tls`            | Not available on the Data Plane; follow [Upgrade from 3.9 to 3.10](https://docs.api7.ai/api7-gateway/upgrade-guides/upgrade-3.9-to-3.10.md) |

## Connection Coverage by Hop[​](#connection-coverage-by-hop "Direct link to Connection Coverage by Hop")

API7 Enterprise secures multiple network boundaries. The table below details PQC key-exchange coverage for each hop on `3.10.9` and later:

| Connection Hop                                                | TLS Implementation                | Hybrid PQC Key Exchange                                                                       | Notes                                                                                                               |
| ------------------------------------------------------------- | --------------------------------- | --------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
| **Client to Gateway (HTTPS / TLS 1.3)**                       | OpenSSL `3.5.9`                   | `X25519MLKEM768` (default)                                                                    | Requires `TLSv1.3` in `apisix.ssl.ssl_protocols` (enabled by default). Older clients fall back to classical curves. |
| **Gateway to Upstream (HTTPS / TLS 1.3)**                     | OpenSSL `3.5.9`                   | `X25519MLKEM768` (default)                                                                    | Negotiated when the upstream supports TLS 1.3 and `X25519MLKEM768`; otherwise falls back to classical curves.       |
| **Data Plane to Control Plane (DP Manager port `7943` mTLS)** | OpenSSL `3.5.9` ↔ Go `crypto/tls` | `X25519MLKEM768` (default)                                                                    | Applies to encrypted mTLS control channels on port `7943`.                                                          |
| **Dashboard, Developer Portal, and Admin API HTTPS**          | Go `crypto/tls`                   | `X25519MLKEM768` (default; Go 1.26+ also offers `SecP256r1MLKEM768` and `SecP384r1MLKEM1024`) | Applies when TLS is terminated directly on the Control Plane services.                                              |
| **Control Plane to External Registries, IdPs, and Webhooks**  | Go `crypto/tls`                   | Default Go hybrid ML-KEM groups                                                               | Active on TLS 1.3 outbound HTTPS calls (Consul, OIDC, webhooks).                                                    |

## Scope[​](#scope "Direct link to Scope")

* **TLS 1.3 Key Exchange**: API7 Enterprise protects TLS 1.3 key agreement with hybrid `X25519MLKEM768` (NIST FIPS 203 `ML-KEM-768` combined with `X25519`). Connections negotiated over TLS 1.2 continue to use classical ECDHE groups.
* **Certificates and Signatures**: Classical RSA and ECDSA certificates are used for TLS authentication while post-quantum digital signature standards (NIST FIPS 204 `ML-DSA` and FIPS 205 `SLH-DSA`) mature across public certificate authorities and client ecosystems.

## Verify PQC Negotiation[​](#verify-pqc-negotiation "Direct link to Verify PQC Negotiation")

### Test with OpenSSL[​](#test-with-openssl "Direct link to Test with OpenSSL")

From a machine with **OpenSSL 3.5 or newer**, verify that the Gateway negotiates `X25519MLKEM768` on TLS 1.3:

```
openssl s_client -connect "<gateway-host>:9443" -servername "<your-domain>" -tls1_3 -groups X25519MLKEM768:X25519 -brief </dev/null
```

Expected output includes:

```
Protocol version: TLSv1.3

Negotiated TLS1.3 group: X25519MLKEM768
```

Verify graceful fallback for a classical-only client:

```
openssl s_client -connect "<gateway-host>:9443" -servername "<your-domain>" -tls1_3 -groups X25519 -brief </dev/null
```

Expected output reports a classical group such as `Peer Temp Key: X25519, 253 bits`.

### Audit PQC Adoption in Gateway Access Logs[​](#audit-pqc-adoption-in-gateway-access-logs "Direct link to Audit PQC Adoption in Gateway Access Logs")

To measure what percentage of client traffic uses `X25519MLKEM768` for compliance reporting, include the NGINX `$ssl_curve` and `$ssl_protocol` variables in the Gateway access log format in `conf/config.yaml`:

conf/config.yaml

```
nginx_config:

  http:

    enable_access_log: true

    access_log_format: '$remote_addr - $remote_user [$time_local] $http_host "$request" $status $body_bytes_sent $request_time "$ssl_protocol" "$ssl_curve"'

    access_log_format_escape: default
```

Connections negotiated with hybrid PQC log `"TLSv1.3" "X25519MLKEM768"`, while classical connections log curves such as `"X25519"` or `"prime256v1"`.

## Configure or Opt Out of Hybrid Key Exchange[​](#configure-or-opt-out-of-hybrid-key-exchange "Direct link to Configure or Opt Out of Hybrid Key Exchange")

Under normal operation, no extra configuration is required. If you need to restrict key-exchange groups or temporarily disable `X25519MLKEM768` while upgrading legacy network equipment, use the options below.

### Data Plane: Restrict Inbound or Upstream Groups[​](#data-plane-restrict-inbound-or-upstream-groups "Direct link to Data Plane: Restrict Inbound or Upstream Groups")

In the Gateway `conf/config.yaml` (or `configurationSnippet.httpSrv` in the API7 Gateway Helm chart), add NGINX directives through `nginx_config.http_server_configuration_snippet`. Use `proxy_ssl_conf_command` to work around legacy network devices that drop the Gateway's oversized outbound `ClientHello` to upstreams; use `ssl_ecdh_curve` only for inbound group policy or to avoid oversized `ServerHello` responses (restricting server-side groups cannot prevent an appliance from dropping an inbound client's `ClientHello`, which is sent before the server responds):

conf/config.yaml

```
nginx_config:

  http_server_configuration_snippet: |

    # Restrict client-to-gateway TLS 1.3 groups to classical curves only:

    ssl_ecdh_curve X25519:prime256v1:secp384r1;



    # Restrict gateway-to-upstream HTTP proxy TLS 1.3 groups to classical curves only:

    proxy_ssl_conf_command Groups X25519:prime256v1:secp384r1;
```

For L4 Stream TLS routes, apply the matching directives under `nginx_config.stream_configuration_snippet`.

To re-enable hybrid PQC explicitly with classical fallbacks, remove those lines or place `X25519MLKEM768` first:

conf/config.yaml

```
nginx_config:

  http_server_configuration_snippet: |

    ssl_ecdh_curve X25519MLKEM768:X25519:prime256v1:secp384r1;

    proxy_ssl_conf_command Groups X25519MLKEM768:X25519:prime256v1:secp384r1;
```

note

`proxy_ssl_conf_command` applies to HTTP/HTTPS proxy upstreams (`proxy_pass`). For `grpcs://` upstreams (`grpc_pass`), also add `grpc_ssl_conf_command Groups X25519:prime256v1:secp384r1;` in `http_server_configuration_snippet`. For the HTTPS Admin API listener, add `ssl_ecdh_curve` in `nginx_config.http_admin_configuration_snippet`.

### Control Plane: Emergency Opt-Out[​](#control-plane-emergency-opt-out "Direct link to Control Plane: Emergency Opt-Out")

If a legacy network appliance blocks outbound hybrid PQC handshakes initiated by the Go-based Control Plane (or if you need the Control Plane to stop selecting ML-KEM groups on inbound handshakes), set the `GODEBUG` environment variable on the affected Control Plane deployment:

```
GODEBUG=tlsmlkem=0,tlssecpmlkem=0
```

Remove the override once the intermediate network device is updated.

## Troubleshooting Legacy Network Devices[​](#troubleshooting-legacy-network-devices "Direct link to Troubleshooting Legacy Network Devices")

Enabling `X25519MLKEM768` adds roughly 1.1 KB to the TLS 1.3 `ClientHello`, increasing total packet size from \~300–500 bytes to \~1,200–1,500 bytes. When the `ClientHello` crosses the path MTU and splits across two TCP segments, older stateful firewalls, load balancers, or DPI appliances may stall or reset the connection.

### Symptoms[​](#symptoms "Direct link to Symptoms")

* Upstream requests time out during the TLS handshake (`upstream timed out` or `SSL_do_handshake() failed` in Gateway error logs) immediately after upgrading to `3.10.9` or later.
* Direct connections to the upstream without the intermediate appliance succeed.

### Isolation and Resolution[​](#isolation-and-resolution "Direct link to Isolation and Resolution")

1. Confirm whether the upstream path fails specifically with a PQC `ClientHello` by testing from a Gateway pod or host network with OpenSSL 3.5+:

   ```
   openssl s_client -connect "<upstream-host>:443" -tls1_3 -groups X25519MLKEM768 -brief </dev/null

   openssl s_client -connect "<upstream-host>:443" -tls1_3 -groups X25519 -brief </dev/null
   ```

2. If `X25519` succeeds while `X25519MLKEM768` stalls or resets, inspect firewalls, NAT gateways, or TLS-inspecting proxies between the Gateway and the upstream and update their firmware to support multi-packet TLS 1.3 `ClientHello` messages.

3. As a temporary mitigation during remediation, apply `proxy_ssl_conf_command Groups X25519:prime256v1:secp384r1;` in `nginx_config.http_server_configuration_snippet` and reload the Gateway.

## Next Steps[​](#next-steps "Direct link to Next Steps")

* Review the [Post-Quantum Cryptography (PQC) Overview](https://docs.api7.ai/post-quantum-cryptography.md) for standards and cross-product comparison.
* Configure [Client mTLS](https://docs.api7.ai/api7-gateway/security-and-compliance/authenticate/client-mtls.md) and [Upstream mTLS](https://docs.api7.ai/api7-gateway/security-and-compliance/authenticate/upstream-mtls.md) for mutual authentication.
* Review [Security Hardening](https://docs.api7.ai/api7-gateway/enterprise-features/security-hardening.md) and [Trust Center](https://docs.api7.ai/api7-gateway/security-and-compliance/trust-center.md).
