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.
Select Certificate
Select Certificate
In Chrome, when you select a certificate, you can change just when you restart the browser. The event OnSelectCertificate is called just a once time. How can I could do select certificate in chromium many times in the same Formulary?
- salvadordf
- Posts: 4620
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Select Certificate
Hi,
Set the GlobalCEFApp.Cache property to a writable directory and use the TChromiumCore.OnSelectClientCertificate event to select a certificate automatically.
The MiniBrowser demo has the code to let the user select a certificate but you can modify it to select it automatically :
https://github.com/salvadordf/CEF4Delphi/blob/55a70a998eeeb5dbba2e8e1db36902ffcc40ebfc/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.pas#L1368
Set the GlobalCEFApp.Cache property to a writable directory and use the TChromiumCore.OnSelectClientCertificate event to select a certificate automatically.
The MiniBrowser demo has the code to let the user select a certificate but you can modify it to select it automatically :
https://github.com/salvadordf/CEF4Delphi/blob/55a70a998eeeb5dbba2e8e1db36902ffcc40ebfc/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.pas#L1368
Re: Select Certificate
I used the MiniBrowser Demo to select certificate, but my problem is when I select a certificate a once, in the next time if I need select another certificate don't work. If I want, I need to close the form and recreate it. I'll explain the steps:
- Creates the form. This form create GlobalCefApp, e so create the chromium.
- Loads URL Default.
- My customer select download to download a XML refer to a government document.
- In the first time he select the certificate, because is the way to site auth his credentials.
- So if his want download another XML to another company where the certificate is different don't work, because the first certificate selected stays.
- Creates the form. This form create GlobalCefApp, e so create the chromium.
- Loads URL Default.
- My customer select download to download a XML refer to a government document.
- In the first time he select the certificate, because is the way to site auth his credentials.
- So if his want download another XML to another company where the certificate is different don't work, because the first certificate selected stays.
- salvadordf
- Posts: 4620
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Select Certificate
Try calling ClearDataForOrigin to clear the storage data for a given origin.
This is an asynchronous function that triggers the TChromiumCore.OnDevToolsMethodResult event when it finishes executing.
Code: Select all
TChromiumCore.ClearDataForOrigin('https://www.mywebsite.com', cdstAll);
Re: Select Certificate
Yeah, I tested this method in Demo MiniBrowser: https://github.com/salvadordf/CEF4Delphi/blob/16639d5ea5d5c6d5fddaa4c771504abb4fbb7641/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.pas#L1373
The ClearCache and ClearDataForOrigin but no one worked. I'm breaking my head, just works when I close the form and recreate them, Idon't know what I do. In the IE, when we used the TWEBBrowser the script "document.execCommand("ClearAuthenticationCache");" was working, but the engine of the Chromium is totally different. If you have more tips, I apreciate.
The ClearCache and ClearDataForOrigin but no one worked. I'm breaking my head, just works when I close the form and recreate them, Idon't know what I do. In the IE, when we used the TWEBBrowser the script "document.execCommand("ClearAuthenticationCache");" was working, but the engine of the Chromium is totally different. If you have more tips, I apreciate.
- salvadordf
- Posts: 4620
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Select Certificate
Create an independent browser with a new request context that uses a different cache directory.
See the MDIBrowser code :
https://github.com/salvadordf/CEF4Delphi/blob/55a70a998eeeb5dbba2e8e1db36902ffcc40ebfc/demos/Delphi_VCL/MDIBrowser/uChildForm.pas#L164
See the MDIBrowser code :
https://github.com/salvadordf/CEF4Delphi/blob/55a70a998eeeb5dbba2e8e1db36902ffcc40ebfc/demos/Delphi_VCL/MDIBrowser/uChildForm.pas#L164
Re: Select Certificate
It's works, but the method is same. A ChildForm need to be closed to work in another ChildForm. So is the same way, a form need to be closed to it works. I tested with a ChildForm embedded in another form but the process is not closed totally so the spend of memory is huge if the customer stays clicking in new browser.
- salvadordf
- Posts: 4620
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Select Certificate
That's the recommended way in this case :
https://stackoverflow.com/questions/66521061/requesting-client-certificate-a-second-time-with-cefsharp
Chromium should eventually stop those unused processes.
https://stackoverflow.com/questions/66521061/requesting-client-certificate-a-second-time-with-cefsharp
Chromium should eventually stop those unused processes.