Repository navigation
Support eMudhra certificate signing - #261
Open
igolaizola wants to merge 1 commit into
Open
igolaizola wants to merge 1 commit into
igolaizola wants to merge 1 commit into
Conversation
Add modern and legacy eMudhra modes with CLI flags and a saved settings API. Preserve the local CA and support EC certificate metadata. Tests: 35 unit tests and five settings API tests pass.
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved client trust-bundle, Electron verification, and Firefox profile-refresh issues can break intercepted HTTPS.
3 open issues
What changed in this PR
Adds modern and legacy eMudhra certificate signing to HTTP Toolkit, with CLI overrides and saved API settings while preserving the local CA.
Changes:
- Adds certificate-mode selection, persistence, and API discovery.
- Supports EC certificate metadata and updates Electron to read the current certificate.
- Adds tests for signing chains, settings persistence, CLI precedence, and local CA restoration.
| File | Description |
|---|---|
| test/unit/https-config.spec.ts | Tests CA selection, TLS chains, and certificate metadata. |
| test/integration/certificate-settings.spec.ts | Tests settings API, persistence, and CLI overrides. |
| test/fixtures/emsign-ecc-root-g3.pem | Adds the modern trust-root fixture. |
| test/fixtures/aaa-certificate-services.pem | Adds the legacy trust-root fixture. |
| src/interceptors/electron.ts | Reads the current certificate during activation. |
| src/index.ts | Wires certificate selection and serialized settings updates. |
| src/https-config.ts | Implements mode selection and persistence, preserving local CA files. |
| src/emudhra.ts | Defines eMudhra signing material and ordered chains. |
| src/config.d.ts | Adds the certificate-mode configuration type. |
| src/commands/start.ts | Adds modern and legacy eMudhra CLI flags. |
| src/certificates.ts | Supports EC metadata through native X.509 parsing. |
| src/api/rest-api.ts | Adds the certificate settings endpoint. |
| src/api/api-server.ts | Passes the certificate-selection callback to the model. |
| src/api/api-model.ts | Exposes certificate modes and applies selection requests. |
Review effort: Balanced
| })({ | ||
| newlineEncodedCertData: "${(await this.certData).replace(/\r\n|\r|\n/g, '\\n')}", | ||
| spkiFingerprint: "${await generateSPKIFingerprint(await this.certData)}" | ||
| newlineEncodedCertData: "${certData.replace(/\r\n|\r|\n/g, '\\n')}", |
| const certContent = mode === 'emudhra-old' ? EMUDHRA_OLD_CHAIN : EMUDHRA_CHAIN; | ||
| await Promise.all([ | ||
| writeFile(keyPath, EMUDHRA_KEY, { mode: 0o600 }), | ||
| writeFile(certPath, certContent) |
| await writeFile(settingsPath + '.tmp', JSON.stringify({ certificateMode: mode })); | ||
| await fs.promises.rename(settingsPath + '.tmp', settingsPath); | ||
| // Proxy defaults and interceptors share this object. | ||
| Object.assign(httpsConfig, nextConfig); |
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.


Add modern and legacy eMudhra modes with CLI flags and a saved settings API. Preserve the local CA and support EC certificate metadata.
Tests: 35 unit tests and five settings API tests pass.