Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make intermediates work with 'select-client-certificate' #29552

Merged
merged 1 commit into from
Jun 7, 2021

Conversation

dsanders11
Copy link
Member

@dsanders11 dsanders11 commented Jun 6, 2021

Description of Change

Fixes #28553.

cc @zcbenz @deepak1556

No test added because I wasn't sure there's a viable way to make one (no current tests for this functionality) since it pulls client certificates from the system store. See #21980.

Manually reproduced and tested the fix. The fix is straight forward, but if anyone else really feels like confirming it themselves, these are the steps I used on macOS, it was a bit of a pain:

  1. In Keychain Access, use Keychain Access -> Certificate Assistant to create a certificate chain, using 'SSL Client' for the type for all certificates. Create:
    1. A self-signed root CA.
    2. An intermediate CA.
    3. A leaf certificate.
  2. Apply the Chromium patch provided below, which ensures Chromium will include intermediates on macOS, otherwise they are only included when the server is limiting the trusted root CAs to a specific list.
  3. Run this gist in Electron Fiddle.
  4. Should see that the SSL_CLIENT_CERT_CHAIN_1 field is populated if the chain was sent to the server.
Chromium Patch for Manual Testing (macOS)

diff --git a/net/ssl/client_cert_store_mac.cc b/net/ssl/client_cert_store_mac.cc
index 7d97f1d090417..62d8e4f1675e3 100644
--- a/net/ssl/client_cert_store_mac.cc
+++ b/net/ssl/client_cert_store_mac.cc
@@ -133,15 +133,16 @@ bool IsIssuedByInKeychain(const std::vector<std::string>& valid_issuers,
                                                          options));
   CFRelease(cert_chain);  // Also frees |intermediates|.
 
-  if (!new_cert || !new_cert->IsIssuedByEncoded(valid_issuers))
-    return false;
-
   std::vector<bssl::UniquePtr<CRYPTO_BUFFER>> intermediate_buffers;
   intermediate_buffers.reserve(new_cert->intermediate_buffers().size());
   for (const auto& intermediate : new_cert->intermediate_buffers()) {
     intermediate_buffers.push_back(bssl::UpRef(intermediate.get()));
   }
   identity->SetIntermediates(std::move(intermediate_buffers));
+
+  if (!new_cert || !new_cert->IsIssuedByEncoded(valid_issuers))
+    return false;
+
   return true;
 }
 
@@ -235,6 +236,8 @@ void GetClientCertsImpl(std::unique_ptr<ClientCertIdentity> preferred_identity,
     if (cert_iter != selected_identities->end())
       continue;
 
+    IsIssuedByInKeychain(request.cert_authorities, cert.get());
+
     // Check if the certificate issuer is allowed by the server.
     if (request.cert_authorities.empty() ||
         cert->certificate()->IsIssuedByEncoded(request.cert_authorities) ||

Checklist

  • PR description included and stakeholders cc'd
  • npm test passes

Release Notes

Notes: Fixed sending intermediate certificates with 'select-client-certificate' event callback

@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Jun 6, 2021
@zcbenz zcbenz added semver/patch backwards-compatible bug fixes target/12-x-y labels Jun 7, 2021
@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Jun 7, 2021
@deepak1556 deepak1556 merged commit 070f25d into electron:main Jun 7, 2021
@release-clerk
Copy link

release-clerk bot commented Jun 7, 2021

Release Notes Persisted

Fixed sending intermediate certificates with 'select-client-certificate' event callback

@trop
Copy link
Contributor

trop bot commented Jun 7, 2021

I have automatically backported this PR to "12-x-y", please check out #29568

@trop
Copy link
Contributor

trop bot commented Jun 7, 2021

I have automatically backported this PR to "13-x-y", please check out #29569

@trop
Copy link
Contributor

trop bot commented Jun 7, 2021

I have automatically backported this PR to "14-x-y", please check out #29570

michal-kalina pushed a commit to solarwindscloud/electron that referenced this pull request Jul 2, 2021
@dsanders11 dsanders11 deleted the patch-30 branch March 14, 2022 02:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver/patch backwards-compatible bug fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: select-client-certificate does not send full certificate chain
3 participants