Skip to content

Support eMudhra certificate signing - #261

Open
igolaizola wants to merge 1 commit into
httptoolkit:mainfrom
igolaizola:emudhra-certificates
Open

igolaizola wants to merge 1 commit into
httptoolkit:mainfrom
igolaizola:emudhra-certificates

Conversation

@igolaizola

Copy link
Copy Markdown

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.

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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')}",
Comment thread src/https-config.ts
const certContent = mode === 'emudhra-old' ? EMUDHRA_OLD_CHAIN : EMUDHRA_CHAIN;
await Promise.all([
writeFile(keyPath, EMUDHRA_KEY, { mode: 0o600 }),
writeFile(certPath, certContent)
Comment thread src/https-config.ts
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);
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.

2 participants