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.

Change Certificate in Application

Post Reply
chemapa
Posts: 5
Joined: Sat Sep 21, 2019 4:06 pm

Change Certificate in Application

Post by chemapa »

Hi all,
I am getting to change a certificate in "OnSelectClientCertificate" event
procedure TBuscaAutDespacho.chr1SelectClientCertificate(Sender: TObject;
const browser: ICefBrowser; isProxy: Boolean; const host: ustring;
port: Integer; certificatesCount: Cardinal;
const certificates: TCefX509CertificateArray;
const callback: ICefSelectClientCertificateCallback; var aResult: Boolean);
begin
aresult:=true;
callback.Select(certificates[myCertIndex]);
end;
It's ok.

I need to change certificate some times along the application execution. I destroy TChromiun but it's inssuficient, the event "OnSelectClientCertificate" is fired one time only. It's necesary reset the application.

What can I do?

Thanks
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Change Certificate in Application

Post by salvadordf »

Hi / Hola Chema,

I can't test certificates right now but I guess it should ask for a new certificate if you logout from that website.

If that isn't enough then try to destroy that browser following the "destruction steps" given in the code comments of every demo and then create a new browser with a new request context as shown in the MDIBrowser demo.

Browsers created with different request contexts are completely independent and they should ask for a new certificate.

In case you haven't read it already, this thread explains how to use those events with CEF4Delphi :
https://www.briskbard.com/forum/viewtopic.php?t=779
chemapa
Posts: 5
Joined: Sat Sep 21, 2019 4:06 pm

Re: Change Certificate in Application

Post by chemapa »

Hi, its perfect.

I write:

if MainForm.NewContextChk.Checked then TempContext := TCefRequestContextRef.New('', '', False, False, False, False) else
TempContext := nil;
Chromium1.CreateBrowser(CEFWindowParent1, '', TempContext);

Thanks
darkducke
Posts: 21
Joined: Thu Feb 15, 2018 4:29 pm

Re: Change Certificate in Application

Post by darkducke »

How to show the window for the user to select the certificate and get its index?
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Change Certificate in Application

Post by salvadordf »

This answer has all the code you need :
https://stackoverflow.com/questions/68006898/cef4delphi-certificate-selection-window
Post Reply