Skip to content

feat: emit select-client-certificate for net module requests - #52397

Merged
jkleinsc merged 13 commits into
44-x-yfrom
trop/44-x-y-bp-feat-emit-select-client-certificate-for-net-module-requests-1784560328477
Jul 23, 2026
Merged

jkleinsc merged 13 commits into
44-x-yfrom
trop/44-x-y-bp-feat-emit-select-client-certificate-for-net-module-requests-1784560328477

Conversation

@trop

@trop trop Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Backport of #52162

See that PR for details.

Notes: Added select-client-certificate event support for net.request and net.fetch; requests to servers requesting a client certificate no longer fail with ERR_SSL_CLIENT_AUTH_CERT_NEEDED, and applications can now select a certificate to present.

trop Bot and others added 13 commits July 20, 2026 15:12
net.request and net.fetch requests to servers that send a TLS
CertificateRequest currently abort with ERR_SSL_CLIENT_AUTH_CERT_NEEDED
because SimpleURLLoaderWrapper::OnCertificateRequested and
URLLoaderNetworkObserver::OnCertificateRequested are empty stubs;
dropping the ClientCertificateResponder pipe causes the network service
to cancel the request. The select-client-certificate event only fired
for BrowserWindow page loads.

Implement OnCertificateRequested for both observers by fetching client
identities via ElectronBrowserClient::CreateClientCertStore() and
routing through the existing ElectronBrowserClient::SelectClientCertificate
path with web_contents = nullptr. When no matching identities exist the
request continues without a certificate, so optional client-certificate
endpoints work without any app-side handler.

Closes #29984.

Notes: Added `select-client-certificate` event support for `net.request` and `net.fetch`; requests to servers with optional client-certificate authentication no longer fail with ERR_SSL_CLIENT_AUTH_CERT_NEEDED.

Co-authored-by: Danny Cochran <[email protected]>
ClientCertificateResponderDelegate calls these on ElectronBrowserClient
directly to route net-module client certificate requests through the
existing app 'select-client-certificate' event path.

Co-authored-by: Danny Cochran <[email protected]>
OnClientCertificateSelected dereferenced an empty v8::Local when the
JS callback was invoked with no arguments: args->GetNext() returned
false and val stayed empty, then val->IsNull() crashed. The
documentation for select-client-certificate says callback() with no
certificate continues without one, so this must work.

Guard for no-argument / empty / null / undefined in one place. This is
pre-existing code shared with the BrowserWindow path, so this also
fixes the same crash for the existing app 'select-client-certificate'
event when callback() is called with no argument.

Co-authored-by: Danny Cochran <[email protected]>
…ener

Shorten the helper-class comments in client_certificate_responder_delegate
and ensure the select-client-certificate handler in api-net-spec is removed
even when the event does not fire (the empty-identity short-circuit), so it
cannot leak onto the global app object across spec files.

Co-authored-by: Danny Cochran <[email protected]>
Mirror content/browser/ssl_private_key_impl.cc and wrap the mojo
SignCallback with WrapCallbackWithDefaultInvokeIfNotRun so a platform
key store that abandons its sign callback (https://crbug.com/40651689)
fails the client-auth handshake with ERR_FAILED instead of leaving the
net.fetch / net.request / utility-process request hung.

Co-authored-by: Danny Cochran <[email protected]>
Extend the select-client-certificate breaking-changes entry to call out
that net.request / net.fetch now default to the first matching platform
client certificate (previously ERR_SSL_CLIENT_AUTH_CERT_NEEDED), and how
to opt out.

Co-authored-by: Danny Cochran <[email protected]>
…tity

When a 'select-client-certificate' listener invokes the callback
synchronously without calling event.preventDefault(), the matched
ClientCertIdentity is std::moved out of shared_identities inside
OnClientCertificateSelected. The fall-through default-selection block
then dereferences (*shared_identities)[0], which is now a moved-from
unique_ptr. Guard for it.

Co-authored-by: Danny Cochran <[email protected]>
Co-authored-by: Danny Cochran <[email protected]>
Co-authored-by: Danny Cochran <[email protected]>
@trop
trop Bot requested a review from a team as a code owner July 20, 2026 15:13
@trop trop Bot added 44-x-y backport This is a backport PR backport/requested 🗳 semver/major incompatible API changes labels Jul 20, 2026
@jkleinsc

Copy link
Copy Markdown
Member

@electron/wg-releases approved this for backport.

@jkleinsc
jkleinsc merged commit c21c442 into 44-x-y Jul 23, 2026
130 of 132 checks passed
@release-clerk

release-clerk Bot commented Jul 23, 2026

Copy link
Copy Markdown

Release Notes Persisted

Added select-client-certificate event support for net.request and net.fetch; requests to servers requesting a client certificate no longer fail with ERR_SSL_CLIENT_AUTH_CERT_NEEDED, and applications can now select a certificate to present.

@jkleinsc
jkleinsc deleted the trop/44-x-y-bp-feat-emit-select-client-certificate-for-net-module-requests-1784560328477 branch July 23, 2026 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

44-x-y backport/approved ✅ backport This is a backport PR semver/major incompatible API changes

Projects

No open projects
Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant