feat(dev-server): support ssl, sslKey, sslCert for HTTPS dev (#142) - #184
Merged
Merged
Conversation
The dev-server builder hard-failed whenever ssl/sslKey/sslCert was set, so projects needing HTTPS in dev (OAuth callbacks, secure-cookie testing, mixed-content debugging, service-worker registration) had to stand up a separate TLS-terminating proxy. ngc-rs now serves HTTPS directly. - dev-server: new TlsConfig (from_pem for explicit material, self_signed via rcgen for the auto-generated case, covering the bind host plus the loopback names). DevServerConfig::with_tls wires the PEM into tiny_http's ssl-rustls backend; the SSE live-reload stream rides the same TLS connection. DevServer::scheme() reports https/http. The private key is redacted from Debug output. - cli: --ssl/--ssl-key/--ssl-cert on serve. resolve_tls enforces both-or- neither cert paths and that key/cert require --ssl; the printed URL uses the right scheme. - builder: options.ts forwards the flags, resolves cert paths against the workspace root, emits an https:// URL, and rejects ssl + proxyConfig (the proxy is the browser-facing endpoint; Node-side TLS termination is out of scope). Schema descriptions updated; README serve section corrected. ssl: true without explicit key/cert mints a throwaway self-signed certificate, matching @angular/build:dev-server; browsers show the usual untrusted-cert warning. Bump version to 0.10.16.
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.
Closes #142.
Honors the
ssl/sslKey/sslCertdev-server options so projects needing HTTPS in dev (OAuth callbacks, secure-cookie testing, mixed-content debugging, service-worker registration) can use ngc-rs without a separate TLS-terminating proxy. Previously the builder hard-failed on any SSL config.Changes
crates/dev-server— newTlsConfig:from_pemfor explicit cert/key material,self_signed(viarcgen) for the auto-generated case, covering the bind host plus the loopback names (localhost,127.0.0.1,::1).DevServerConfig::with_tlsfeeds the PEM intotiny_http'sssl-rustlsbackend, and the SSE live-reload stream rides the same TLS connection.DevServer::scheme()reportshttps/http. The private key is redacted fromDebug.crates/cli—--ssl,--ssl-key,--ssl-certonserve.resolve_tlsenforces both-or-neither cert paths and that key/cert require--ssl; the printed URL uses the correct scheme.packages/builder—options.tsforwards the flags, resolves cert paths against the workspace root, emits anhttps://URL, and rejectsssl+proxyConfig. Schema descriptions updated; READMEservesection corrected.ssl: truewithout explicit key/cert mints a throwaway self-signed certificate (matching@angular/build:dev-server); browsers show the usual untrusted-certificate warning.Out of scope
sslcombined withproxyConfigis rejected with an actionable error — the proxy is the browser-facing endpoint, so HTTPS would need Node-side TLS termination + cert coordination. Tracked as a follow-up.Verification
TlsConfig,resolve_tls, andbuildSslArgs.cargo clippy -D warningsclean; changed files passfmt --check; builder lint + 78 TS tests green.ngc-rs serve --sslagainst a real project bootshttps://…;curl -kreturns 200 over a TLS 1.3 handshake with thercgenself-signed cert (verify code 18 = self-signed).Version bumped to 0.10.16.