feat: optional TLS/HTTPS support via env vars - #11
Merged
Conversation
…note - src/index.ts: wrap cert/key reads in try/catch, exit 1 with a clear message instead of an unhandled exception + stack trace - charts README: document that cert rotation needs a pod restart (rollout restart / Reloader) since certs are read once at startup
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.
Refs #10 (left open intentionally for verification).
Adds optional HTTPS support, fully opt-in — when the new env vars are unset the server behaves exactly as before (plain HTTP).
Changes
src/index.ts: readTLS_CERT_PATH/TLS_KEY_PATHand passcert/keytoDeno.serve. Both must be set together — setting only one exits with a config error. If the files can't be read, the server exits1with a clear message instead of an unhandled exception. No new permissions needed (--allow-readwas already granted).src/tls.test.ts+src/fixtures/tls/: unit test that bootsDeno.servewith TLS and hits/healthover HTTPS. Fixtures are a proper CA + leaf chain (SANlocalhost,127.0.0.1, long-lived) — a single self-signed cert is rejected by rustls asCaUsedAsEndEntity.e2e/https.test.ts: curl-based e2e that drives the realsrc/index.tsprocess over HTTPS and exercises a full PUT → GET round-trip through the S3 emulator (curl honors--cacert, so it can validate the fixture CA — the path Nx's native client cannot take). Uses a dedicated emulator port (4567) to avoid colliding with the Nx e2e suite..env.example(new): full env template with commented TLS vars.tls.enabled=falseby default): mounts cert/key from an existing Secret (e.g. cert-managerkubernetes.io/tls), wiresTLS_CERT_PATH/TLS_KEY_PATH, and switches the liveness/readiness probes toscheme: HTTPS(otherwise the pod never goes Ready under TLS). The chart README also documents that cert rotation requires a pod restart (rollout restart / Reloader), since certs are read once at startup.While adding e2e coverage I hit a real constraint worth documenting:
Because this can't be made portably green in CI (the only cert we can self-generate is self-signed, which Nx won't trust without OS-level install), the Nx-driven HTTPS e2e variant was dropped and the constraint is documented in the README instead. Server-side HTTPS behavior is still covered end-to-end by the curl-based e2e above and the TLS unit test.
Verification
deno lint+deno fmt --check— cleandeno task test— passes, incl. the new TLS unit testdeno task e2e— passes, incl. the curl-based HTTPS round-triphelm lint+helm template: default → no TLS artifacts;tls.enabled=true --set tls.secretName=…→ volume/env/scheme: HTTPSrendered;tls.enabled=truewithoutsecretName→ fails with arequirederrorcurl --cacert ca.pem https://localhost:.../health→OK