tools/testcerts: dynamically generate integration test certs via BoringSSL C++ tool + Bazel genrule#44331
Draft
tools/testcerts: dynamically generate integration test certs via BoringSSL C++ tool + Bazel genrule#44331
Conversation
- Integration certs (test/config/integration/certs/): expired Apr 8, 2026 → now valid until Apr 2036 - TLS test data certs (test/common/tls/test_data/): expiring Aug 2026 → now valid until Apr 2036 - OCSP test data certs (test/common/tls/ocsp/test_data/): expiring Oct 2026 → now valid until Apr 2036 - Compat openssl certs (compat/openssl/test/certs/): expiring Jun 2027 → now valid until Apr 2036 - Add bad_rsa_key_usage cert generation to test_data/certs.sh (was expired since Jan 2025) - Fix certs.sh scripts to use DEFAULT_VALIDITY_DAYS=3650 consistently - Fix OCSP certs.sh: separate -signkey and -CA options (OpenSSL 3.0 compatibility) - Intentionally expired/special certs preserved as-is Agent-Logs-Url: https://github.com/envoyproxy/envoy/sessions/4637b04d-df2c-42fd-ac8b-4c6ab17be2c6 Co-authored-by: phlax <454682+phlax@users.noreply.github.com>
… integration certs - Add tools/testcerts/generate_test_certs.cc: C++ tool using BoringSSL X509 APIs to generate all standard integration test certificates. No openssl CLI dep. Produces: RSA/ECDSA certs, CA chains, OCSP responses (.der), info/hash headers. - Add tools/testcerts/BUILD: cc_binary target using //bazel:crypto and //bazel:ssl - Update test/config/integration/certs/BUILD: replace checked-in PEM/DER/header files with a genrule that runs the generator at build time (Bazel-cached) - Remove 54 generated cert files from source control; only special static files remain: expired_cert.pem, google_root_certs.pem, pqc_cacert.pem (etc.) - Fixes: #23912 (use Bazel to generate test certificates dynamically) Agent-Logs-Url: https://github.com/envoyproxy/envoy/sessions/4637b04d-df2c-42fd-ac8b-4c6ab17be2c6 Co-authored-by: phlax <454682+phlax@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add C++ tool to generate test certificates during Bazel build
tools/testcerts: dynamically generate integration test certs via BoringSSL C++ tool + Bazel genrule
Apr 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Envoy's checked-in test certificates expire every ~2 years, triggering recurring fire drills (46 files touched in Apr 2024, same situation again Apr 2026). This PR both fixes the immediate expiry and eliminates the root cause.
Immediate fix
Regenerated all expired/expiring certificates across all four cert directories with 10-year validity (expires 2036). Fixed OpenSSL 3.0 compatibility issues in
certs.shscripts (separate-signkey/-CAflags,DEFAULT_VALIDITY_DAYSvariable).Long-term fix: C++ BoringSSL generator + Bazel genrule
tools/testcerts/generate_test_certs.ccPure C++ cert generator using BoringSSL X509 APIs — no
opensslCLI, noforeign_cc. Produces the fulltest/config/integration/certs/hierarchy:openssl/ocsp.h)*_info.hand*_hash.hC++ header files with SHA-256, SHA-1, SPKI, serial, and validity metadatatest/config/integration/certs/BUILDReplaces checked-in files with a
genrule— Bazel builds and caches the certs like any other artifact:54 previously checked-in PEM/DER/header files are removed. The following intentionally special certs remain as static checked-in files:
expired_cert.pem/expired_key.pem— tests reference a hardcoded expiry timestampgoogle_root_certs.pem— real Google root cert for gRPC testspqc_cacert.pem/pqc_cakey.pem— post-quantum crypto test certOriginal prompt
Use Bazel to dynamically generate test certificates instead of checking them in
Context & Motivation
Envoy has a recurring problem where checked-in test certificates expire every ~2 years, breaking CI across main and all release branches. This has happened multiple times (see #23912, PR #33389 which touched 46 files just to re-issue certs in April 2024). The current date is April 2026, meaning we're hitting this cycle again.
The goal is to generate test certificates dynamically at Bazel build time using BoringSSL's C++ X509 APIs (which Envoy already depends on as
@boringssl), eliminating the need for checked-in PEM files that rot over time.Requirements
Create a C++ certificate generator tool (
cc_binary) that uses BoringSSL's X509 APIs directly:foreign_ccdependency needed — BoringSSL builds natively with BazelopensslCLI dependency//bazel:cryptoand//bazel:sslas deps (Envoy's existing BoringSSL aliases)The generator must produce the full test certificate hierarchy that Envoy tests need:
Bazel integration via
genrule:action_envwith a cache epoch (e.g.,CERT_EPOCH=2026Q2) to allow forced regeneration on a schedule, or just set validity to 10+ yearsPreserve intentionally-special certs:
Investigation needed:
test/directories)opensslCLI that document what properties the certs need)The generator should be extensible — as new test scenarios require new cert types, developers should be able to add them to the generator rather than manually creating and checking in new PEMs.
References
test/subdirectories@boringsslwith Bazel-native build, aliases at//bazel:cryptoand//bazel:sslAcceptance Criteria
cc_binarytool undertools/ortest/that generates all standard test certificates using BoringSSL APIsgenrule(or similar) that produces the PEM files as Bazel build outputsThe following is the prior conversation context from the user's chat exploration (may be truncated):
User: anything like rules_openssl for bazel pre-existing ?
Assistant: Yes, there are pre-existing options for using OpenSSL with Bazel:
1. Bazel Central Registry (
opensslmodule) — Recommended for BzlmodYou can add OpenSSL directly via Bzlmod in your
MODULE.bazel:This is the most idiomatic approach if you're using modern Bazel with Bzlmod [1].
2.
bazel-rules-openssl(GitHub)There's a dedicated GitHub repo — 3rdparty/bazel-rules-openssl — that provides Bazel rules, macros, and repository definitions for building OpenSSL. This is useful for
WORKSPACE-based setups or if you need more control over how OpenSSL is fetched/built [2].TL;DR: If you're on Bzlmod, use the BCR
opensslmodule. If you need aWORKSPACE-style integration or more customization, check out3rdparty/bazel-rules-openssl.This pull request was created from Copilot chat.