Skip to content

feat: Implement password delegate for NSS #41205

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

Merged
merged 7 commits into from
Jul 17, 2024

Conversation

arenevier
Copy link
Contributor

@arenevier arenevier commented Feb 1, 2024

Description of Change

Closes #41188

Introduce an app event client-certificate-request-password. It allows the user to display a UI to prompt for the password.

An alternative would have been to implement a class similar to CryptoModulePasswordDialogView, to provide the UI. This might have been simpler for the user, comparing to letting them implement the UI. But it seems like electron does not have an i18n framework, so it's not possible to provide a locale aware UI.

Checklist

Release Notes

Notes: Add the event client-certificate-request-password to app. It is dispatched when a PIN is needed to unlock a cryptographic device.

Copy link

welcome bot commented Feb 1, 2024

💖 Thanks for opening this pull request! 💖

We use semantic commit messages to streamline the release process. Before your pull request can be merged, you should update your pull request title to start with a semantic prefix.

Examples of commit messages with semantic prefixes:

  • fix: don't overwrite prevent_default if default wasn't prevented
  • feat: add app.isPackaged() method
  • docs: app.isDefaultProtocolClient is now available on Linux

Things that will help get your PR across the finish line:

  • Follow the JavaScript, C++, and Python coding style.
  • Run npm run lint locally to catch formatting errors earlier.
  • Document any user-facing changes you've made following the documentation styleguide.
  • Include tests when adding/changing behavior.
  • Include screenshots and animated GIFs whenever possible.

We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can.

@electron-cation electron-cation bot added the new-pr 🌱 PR opened recently label Feb 1, 2024
@arenevier
Copy link
Contributor Author

This event is only dispatched when NSS requires a certificate to unlock a certificate. This typically happens when the client certificate is stored on a smart card. So I really don't know how to add a test for that. If you think of a way to do, I will be happy to add some unit tests.

@codebytere codebytere changed the title feat: Implement password delegate for NSS (#41188) feat: Implement password delegate for NSS Feb 1, 2024
@zcbenz zcbenz requested a review from ckerr February 8, 2024 01:16
@zcbenz zcbenz added platform/linux semver/minor backwards-compatible functionality no-backport labels Feb 8, 2024
@electron-cation electron-cation bot added api-review/requested 🗳 and removed new-pr 🌱 PR opened recently labels Feb 8, 2024
@arenevier
Copy link
Contributor Author

Do you have feedback about that pull request?

@zcbenz zcbenz requested a review from a team March 4, 2024 01:18
@arenevier arenevier closed this Mar 5, 2024
@arenevier arenevier force-pushed the password_delegate branch from 861bbee to cc7e80c Compare March 5, 2024 22:41
@arenevier arenevier reopened this Apr 18, 2024
@arenevier
Copy link
Contributor Author

I had closed the pull request by accident. I'm still looking for reviews

@arenevier arenevier requested a review from codebytere April 19, 2024 17:58
Copy link
Member

@samuelmaddock samuelmaddock left a comment

Choose a reason for hiding this comment

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

API LGTM

gin_helper::internal::Event::New(isolate);
v8::Local<v8::Object> event_object = event.ToV8().As<v8::Object>();
gin_helper::Dictionary dict(isolate, event_object);
dict.Set("hostName", server_.host());
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
dict.Set("hostName", server_.host());
dict.Set("hostname", server_.host());

Based on casing seen in other APIs (setCertificateVerifyProc)

Comment on lines +1503 to +1515
const { app } = require('electron')

async function passwordPromptUI (text) {
return new Promise((resolve, reject) => {
// display UI to prompt user for password
// ...
// ...
resolve('the password')
})
}
Copy link
Member

Choose a reason for hiding this comment

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

Would be great if we had a working example here. It's too bad our dialog API doesn't support basic input prompting 🥲

@samuelmaddock
Copy link
Member

@arenevier rebasing your PR might fix the build errors being seen

@samuelmaddock
Copy link
Member

I'm adding a wip label on this PR until the requested changes can be implemented. Please tag @electron/wg-api once it's ready to be reviewed again and we'll take another look! 🙇

Arno Renevier added 4 commits June 24, 2024 10:49
Introduce an app event client-certificate-request-password. It allows
the user to display a UI to prompt for the password.

An alternative would have been to implement a class similar to
CryptoModulePasswordDialogView, to provide the UI. This might have been
simpler for the user, comparing to letting them implement the UI. But it
seems like electron does not have an i18n framework, so it's not
possible to provide a locale aware UI.
* use a trampoline handler in JS. The api exposed is now app.setClientCertRequestPasswordHandler
* use properties on the Event object instead of positional parameters
* remove ChromeNSSCryptoModuleDelegate::OnPassword in favor of args->GetNext(&password_)
- backslash escape parametrized TypeScript
- rename hostName param to hostname
- use base::ScopedAllowBaseSyncPrimitivesForTesting
- and then, rename ChromeNSSCryptoModuleDelegate to ElectronNSSCryptoModuleDelegate
@arenevier arenevier force-pushed the password_delegate branch from 6ecab9d to 5dbb7bf Compare June 24, 2024 17:50
@arenevier arenevier requested a review from samuelmaddock June 24, 2024 17:50
@arenevier
Copy link
Contributor Author

@electron/wg-api: I have updated the patch. I think I addressed all the comments.

@arenevier
Copy link
Contributor Author

@electron/api-wg

@arenevier
Copy link
Contributor Author

@samuelmaddock: I'm pinging you directly because I'm not sure if the ping to electron/wg-api worked or not

Copy link
Member

@samuelmaddock samuelmaddock left a comment

Choose a reason for hiding this comment

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

API LGTM

Co-authored-by: Sam Maddock <[email protected]>
Co-authored-by: Erick Zhao <[email protected]>
Copy link
Member

@erickzhao erickzhao left a comment

Choose a reason for hiding this comment

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

API LGTM

@arenevier
Copy link
Contributor Author

@codebytere @ckerr : could one of you take a look?

@samuelmaddock
Copy link
Member

@arenevier we've recently started deploying GitHub actions to run builds/tests for Electron. We're working through some issues with them running in PRs from forked repos. I'll try to get back to you next week once we've resolved the issue so we can get this PR back to a ✅ state and hopefully merged soon.

@samuelmaddock
Copy link
Member

@arenevier would you mind rebasing to the latest changes on main? It should resolve the CI errors.

@arenevier
Copy link
Contributor Author

@arenevier would you mind rebasing to the latest changes on main? It should resolve the CI errors.

Looks like there is still an issue.

@jkleinsc jkleinsc merged commit 81bdba6 into electron:main Jul 17, 2024
49 checks passed
Copy link

welcome bot commented Jul 17, 2024

Congrats on merging your first pull request! 🎉🎉🎉

@release-clerk
Copy link

release-clerk bot commented Jul 17, 2024

Release Notes Persisted

Add the event client-certificate-request-password to app. It is dispatched when a PIN is needed to unlock a cryptographic device.

golshanaramesh

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: [linux] Cannot use client certificates protected by password
8 participants