Skip to content

feat: Support custom CA bundle for corporate SSL inspection#88

Merged
huseyinbabal merged 2 commits intomasterfrom
feature/custom-ca-bundle
Jan 15, 2026
Merged

feat: Support custom CA bundle for corporate SSL inspection#88
huseyinbabal merged 2 commits intomasterfrom
feature/custom-ca-bundle

Conversation

@huseyinbabal
Copy link
Owner

Summary

Add support for AWS_CA_BUNDLE and SSL_CERT_FILE environment variables to allow taws to work behind corporate proxies with SSL inspection.

Closes #66

Problem

In corporate environments with SSL inspection, taws hangs or fails because:

  • Proxy intercepts HTTPS traffic and re-signs with corporate CA
  • Corporate CA is not in webpki-roots default trust store
  • No way to configure custom CA certificates

Solution

New TLS Module (src/aws/tls.rs)

  • Load CA certificates from AWS_CA_BUNDLE or SSL_CERT_FILE
  • Support PEM files with multiple certificates (certificate chains)
  • Cache certificates for application lifetime
  • Configure all HTTP clients with custom CA and timeouts

Timeouts

  • Connect timeout: 10 seconds (prevents hanging on TLS issues)
  • Request timeout: 30 seconds

Updated Components

  • src/aws/http.rs - Main AWS API client
  • src/aws/sso.rs - SSO OIDC clients
  • src/aws/credentials.rs - STS AssumeRole client

Usage

# Windows
set AWS_CA_BUNDLE=C:\path\to\corporate-ca-bundle.pem
taws

# Linux/macOS
export AWS_CA_BUNDLE=/path/to/corporate-ca-bundle.pem
taws

The PEM file can contain multiple certificates. This is the same environment variable used by AWS CLI, so if AWS CLI works with your CA bundle, taws should work too.

Testing

  • Added unit tests for certificate parsing
  • 73 tests pass
  • Clippy passes

Notes

  • If neither env var is set, default webpki-roots bundle is used (existing behavior)
  • Warnings logged if CA bundle file is missing or invalid (falls back to default)
  • IMDS and ECS container credentials don't use custom CA (local endpoints)

Add support for AWS_CA_BUNDLE and SSL_CERT_FILE environment variables
to allow taws to work behind corporate proxies with SSL inspection.

Changes:
- New src/aws/tls.rs module for TLS configuration utilities
- Load and cache CA certificates from AWS_CA_BUNDLE or SSL_CERT_FILE
- Support PEM files with multiple certificates (certificate chains)
- Apply custom CA to all HTTP clients (AWS API, SSO, STS AssumeRole)
- Add connect timeout (10s) and request timeout (30s) to prevent hangs
- Log warnings when CA bundle file is missing or invalid

The CA bundle is loaded once and cached for the lifetime of the
application. If neither environment variable is set, taws uses
the default webpki-roots CA bundle.

This enables taws to work in corporate environments where:
- SSL/TLS inspection proxies intercept HTTPS traffic
- Corporate CA certificates are not in the default trust store
- AWS CLI works when AWS_CA_BUNDLE is set

Closes #66
…undle

- Parse certificates individually from PEM bundle instead of as a single blob
- Use binary search to efficiently filter out invalid certificates
- Skip certificates that rustls cannot validate (e.g., unsupported extensions)
- Keep built-in root certs when adding custom CA certificates
- Add better debug logging with {:?} format for error details

This fixes the 'UnsupportedCriticalExtension' error when using CA bundles
from corporate environments with SSL inspection proxies.
@huseyinbabal huseyinbabal merged commit 5328dfb into master Jan 15, 2026
4 checks passed
@huseyinbabal huseyinbabal deleted the feature/custom-ca-bundle branch January 15, 2026 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows: Support corporate SSL roots (native roots/native‑tls) or custom CA bundle — connections hang behind SSL inspection

1 participant