Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
Use of the method OnSelectClientCertificate
Use of the method OnSelectClientCertificate
Hello. I don't know much about the framework, I need to implement certificate selection in a browser. I then discovered that I need to implement this method. However, I am not able to make the certificate selection screen appear. Would anyone have an example or some 'for dummies' explanation of this please. Thanks.
- salvadordf
- Posts: 4575
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Use of the method OnSelectClientCertificate
Hi,
These are the code comments for the TChromium.OnSelectClientCertificate event :
They are available here :
https://bitbucket.org/chromiumembedded/ ... #lines-209
and here :
https://magpcss.org/ceforum/apidocs3/pr ... llback%3E)
Many TChromium events, including this one, are executed in a CEF thread which is different than the main application thread. As you know, VCL is not thread-safe so you will have to save the values of some parameters and send a windows message to the main form to show the certificate selection interface in the main application thread.
You need to copy the "callback" and "certificates" parameters, set "aResult" to TRUE and send a message to the form in order to allow the user to select a certificate at a later time.
The form will receive your custom message, show the certificate selection interface and call "callback.Select" with the selected certificate.
Here you have the documentation about the callback parameter :
https://magpcss.org/ceforum/apidocs3/pr ... lback.html
The "certificates" parameter is just an array of ICefX509Certificate. Read this for more information about them if you need to show the details to the user :
https://magpcss.org/ceforum/apidocs3/pr ... icate.html
After all that you should set all your copies to NIL to avoid shutdown issues in your application.
These are the code comments for the TChromium.OnSelectClientCertificate event :
Code: Select all
///
// Called on the UI thread when a client certificate is being requested for
// authentication. Return false (0) to use the default behavior and
// automatically select the first certificate available. Return true (1) and
// call cef_select_client_certificate_callback_t::Select either in this
// function or at a later time to select a certificate. Do not call Select or
// call it with NULL to continue without using any certificate. |isProxy|
// indicates whether the host is an HTTPS proxy or the origin server. |host|
// and |port| contains the hostname and port of the SSL server. |certificates|
// is the list of certificates to choose from; this list has already been
// pruned by Chromium so that it only contains certificates from issuers that
// the server trusts.
///
https://bitbucket.org/chromiumembedded/ ... #lines-209
and here :
https://magpcss.org/ceforum/apidocs3/pr ... llback%3E)
Many TChromium events, including this one, are executed in a CEF thread which is different than the main application thread. As you know, VCL is not thread-safe so you will have to save the values of some parameters and send a windows message to the main form to show the certificate selection interface in the main application thread.
You need to copy the "callback" and "certificates" parameters, set "aResult" to TRUE and send a message to the form in order to allow the user to select a certificate at a later time.
The form will receive your custom message, show the certificate selection interface and call "callback.Select" with the selected certificate.
Here you have the documentation about the callback parameter :
https://magpcss.org/ceforum/apidocs3/pr ... lback.html
The "certificates" parameter is just an array of ICefX509Certificate. Read this for more information about them if you need to show the details to the user :
https://magpcss.org/ceforum/apidocs3/pr ... icate.html
After all that you should set all your copies to NIL to avoid shutdown issues in your application.