Skip to content

browser: support client certificate - #1859

Merged
zcbenz merged 2 commits into
electron:masterfrom
deepak1556:client_certificate_patch
Jun 10, 2015
Merged

zcbenz merged 2 commits into
electron:masterfrom
deepak1556:client_certificate_patch

Conversation

@deepak1556

Copy link
Copy Markdown
Member

Fixes #1221

  • Tests

@zcbenz

zcbenz commented Jun 8, 2015

Copy link
Copy Markdown
Contributor

It seems that Chrome reads from cert_request_info->client_certs instead of letting user choose a custom file?

@deepak1556

Copy link
Copy Markdown
Member Author

It seems that Chrome reads from cert_request_info->client_certs instead of letting user choose a custom file?

yup that is the default behaviour where a user selects from the dialog populated with certificates from the system store, but i am trying to address 1 & 2 here . So if a user doesnt provide local client certificate , will fallback to the default behaviour (which havnt handled yet, because of unimplemented table dialog view).

@zcbenz

zcbenz commented Jun 8, 2015

Copy link
Copy Markdown
Contributor

We can choose the first matched certificate as default behavior, so users don't have to do anything to get client certificate support for free.

For further support when a certificate is requested we can probably emit a new event with available certificates and a callback to pass the selected one, this can be done in another PR.

@deepak1556
deepak1556 force-pushed the client_certificate_patch branch from 9e2a7cc to f60c5cf Compare June 8, 2015 16:05
@deepak1556

Copy link
Copy Markdown
Member Author

If local certificate path is not provided, will default to first certificate from the cert store currently.

Depends on electron-archive/brightray#115

@deepak1556

Copy link
Copy Markdown
Member Author

@zcbenz for default auto-selection , user needs to provide a certificate filter . Currently i am thinking of following chrome's web preference filter pattern . Thoughts ?

  {
     "pattern": "[*.]example.com",
     "filter": {
        "ISSUER": {
          "CN": "some name"
        }
     }
   }

/cc @kjlaw89 @thojansen

@kjlaw89

kjlaw89 commented Jun 8, 2015

Copy link
Copy Markdown

That looks good to me, definitely simple enough.

@thojansen

Copy link
Copy Markdown

👍 looks good. ISSUER.CN would be the most important value for us

Comment thread atom/browser/atom_browser_client.cc Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should check for the case when certificate is empty.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

should it be checked ? if the certificate is empty the auth will abort.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Calling ContinueWithCertificate with nullptr will finally reach here:
https://code.google.com/p/chromium/codesearch#chromium/src/net/url_request/url_request_job.cc&sq=package:chromium&type=cs&l=226

The code you were referencing checks for handle not cert.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

fixed.

@zcbenz

zcbenz commented Jun 9, 2015

Copy link
Copy Markdown
Contributor

@zcbenz for default auto-selection , user needs to provide a certificate filter . Currently i am thinking of following chrome's web preference filter pattern . Thoughts ?

We can provide an API to make it possible to choose which certificate to use in JavaScript, so developers can either filter out the one they want, or show the available certificates in GUI to let final users decide.

app.setClientCertificateSelector (webContents, sslCertRequestInfo, callback) ->
  callback(sslCertRequestInfo.certificates[0]);

(It can be implemented in another PR.)

@deepak1556
deepak1556 force-pushed the client_certificate_patch branch from f60c5cf to 52b2c0d Compare June 9, 2015 07:39
@zcbenz

zcbenz commented Jun 9, 2015

Copy link
Copy Markdown
Contributor

👍

zcbenz added a commit that referenced this pull request Jun 10, 2015
@zcbenz
zcbenz merged commit 2fdc578 into electron:master Jun 10, 2015
@kjlaw89

kjlaw89 commented Jun 11, 2015

Copy link
Copy Markdown

Hey @deepak1556, now that this was released I was able to give it a shot today. It definitely works selecting the first certificate from the store, but I was unable to get the command line switch to work how I would expect. Here's the code I was using:

var app = require ('app');
app.commandLine.appendSwitch ('client-certificate', process.cwd () + '\\mycertificate.p12');
console.log (process.cwd () + "\\mycertificate.p12");

I did verify that the path to the certificate is correct. The p12 actually contains a password, which I'm guessing this method doesn't support, but I did do a .pem that does not have a password and I know works but still did not have any luck. Am I missing something?

@deepak1556

Copy link
Copy Markdown
Member Author

@kjlaw89 yup this method currently supports only PEM encoded data, but your code does seem fine. Just tested on OSX, havnt tested on windows though. It would be nice if you could open an issue on the repo to track it. Btw how are you generating the pem file ?

@kjlaw89

kjlaw89 commented Jun 12, 2015

Copy link
Copy Markdown

@deepak1556 Okay, I opened up an issue for it. I'm not sure exactly what program we're using to generate the PEM files, but there's a pretty common Windows one. We normally create .p12 for our clients, which they just then install in the system certificate store and those work on all browsers. The .pem files are generated using the same method. Is there anything specific about the certificate that you want me to check or verify?

@deepak1556

Copy link
Copy Markdown
Member Author

@kjlaw89 i was testing with https://github.com/thojansen/client-certificates/blob/master/ssl/setup.sh , except was importing .pem from .p12 using openssl after the last step (which is plain text with both Certificate and private key). Just to be sure is you PEM file encrypted ?

@kjlaw89

kjlaw89 commented Jun 12, 2015

Copy link
Copy Markdown

@deepak1556 I believe the process we use does the exact same thing, just behind the scenes. I don't think the PEM file is encrypted, but I'd have to check to be certain. I do know that the PEM file I was using does not require a password, unlike the .p12 that I was using.

The PEM also contains both the certificate and private key I believe.

@kjlaw89

kjlaw89 commented Jun 22, 2015

Copy link
Copy Markdown

Hey @deepak1556, have you had any luck fixing this? I'm starting full swing into my development now, so it'd be cool if this was resolved. I you need me to I can provide you a certificate that we generate with a limited access to our server so you can test with what we have.

Thanks again for your work on this! Don't forget to claim the bounty when it's all done!

@deepak1556

Copy link
Copy Markdown
Member Author

@kjlaw89 didn't try since wasn't sure of what was missing in the certificate generation. Yeah it would be great if you could provide the certificate or the process of generation.

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.

4 participants