fix(core): support non-RSA TLS certs and add --https / --ssl-{cert,key} flags#12065
Open
bmaurer wants to merge 1 commit into
Open
fix(core): support non-RSA TLS certs and add --https / --ssl-{cert,key} flags#12065bmaurer wants to merge 1 commit into
bmaurer wants to merge 1 commit into
Conversation
…-ssl-key CLI flags Two related fixes to `getHttpsConfig` in `docusaurus start`: 1. The validator in `getHttpsConfig.ts` used `crypto.publicEncrypt` / `crypto.privateDecrypt` to sanity-check the cert/key pair, but those APIs only work for RSA keys. Passing ECDSA (or EdDSA) certs — common in many corporate PKI setups — caused the dev server to throw `operation not supported for this keytype` even though the cert is fine. Replaced with `crypto.X509Certificate` + `crypto.createPrivateKey`, which work for any key type and additionally catch genuine cert/key-pair mismatches (the old code silently produced garbage in that case rather than throwing). 2. Certs could previously only be supplied via the `SSL_CRT_FILE` and `SSL_KEY_FILE` environment variables. Added matching `--ssl-cert <path>`, `--ssl-key <path>`, and `--https` CLI flags. CLI takes precedence; passing both `--ssl-cert` and `--ssl-key` implies HTTPS.
✅ [V2]Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
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.
Pre-flight checklist
Motivation
Two related fixes to
getHttpsConfigindocusaurus start:The validator in
getHttpsConfig.tsusedcrypto.publicEncrypt/crypto.privateDecryptto sanity-check the cert/key pair, but those APIs only work for RSA keys. Passing ECDSA (or EdDSA) certs — common in many corporate PKI setups — caused the dev server to throwoperation not supported for this keytypeeven though the cert is fine.Replaced with
crypto.X509Certificate+crypto.createPrivateKey, which work for any key type and additionally catch genuine cert/key-pair mismatches (the old code silently produced garbage in that case rather than throwing).Certs could previously only be supplied via the
SSL_CRT_FILEandSSL_KEY_FILEenvironment variables. Added matching--ssl-cert <path>,--ssl-key <path>, and--httpsCLI flags. CLI takes precedence; passing both--ssl-certand--ssl-keyimplies HTTPS.Test Plan
Unit tests
Extended
getHttpsConfig.test.tsfrom 5 to 13 tests. The original 5 still pass (no behavior change for the RSA happy path). New coverage:getHttpsConfig({ sslCert, sslKey })reads from CLI options when no env vars are set.You specified --ssl-cert...error (the env-var path still reportsSSL_CRT_FILE in your env...).--ssl-cert+--ssl-keytogether implies HTTPS without--https.--httpsalone returnstrue.New ECDSA fixtures generated with
openssl ecparam -name prime256v1are committed alongside the existing RSA fixtures.Manual
Generated a self-signed P-256 cert and ran:
Server starts,
curl --cacert ./host.crt https://localhost:3000/returns 200 withverify=0. Without this PR the same invocation fails at startup with theunsupported keytypeerror frompublicEncrypt.Test links
Deploy preview: https://deploy-preview-_____--docusaurus-2.netlify.app/
Related issues/PRs
None.