Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 105 additions & 0 deletions apps/gateway/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions apps/gateway/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ tokio-rustls = "0.26"
rustls = { version = "0.23", features = ["ring"] }
rustls-pemfile = "2"

# X.509 parsing (mTLS client-certificate identity extraction — CN/URI SANs)
x509-parser = "0.16"

# WebSocket upstream TLS root certificates
webpki-roots = "0.26"

Expand Down
16 changes: 13 additions & 3 deletions apps/gateway/src/ca.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ impl CertificateAuthority {
der_to_pem(self.ca_cert_der.as_ref())
}

/// Return the raw CA certificate DER.
/// Used by `client_ca::MtlsConfig::from_env` to reject a `GATEWAY_CLIENT_CA`
/// that is (accidentally or maliciously) this same CA — see the SECURITY
/// note in `client_ca.rs`.
pub(crate) fn ca_cert_der(&self) -> &CertificateDer<'static> {
&self.ca_cert_der
}

/// Load CA from PEM strings (key + certificate).
/// Used when CA is provided via environment variables (cloud mode).
fn load_from_pem(key_pem: &str, cert_pem: &str) -> Result<Self> {
Expand Down Expand Up @@ -333,9 +341,11 @@ mod tests {

fn ensure_crypto_provider() {
INIT_CRYPTO.call_once(|| {
rustls::crypto::ring::default_provider()
.install_default()
.expect("install CryptoProvider");
// Ignore the error: it just means another test module (e.g.
// `client_ca`) already installed the process-wide default in this
// same test binary — a no-op for our purposes either way, since
// it's the same `ring` provider.
let _ = rustls::crypto::ring::default_provider().install_default();
});
}

Expand Down
Loading