Page 1 of 1

Change Certificate in Application

Posted: Sat Sep 21, 2019 10:51 pm
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

Re: Change Certificate in Application

Posted: Sun Sep 22, 2019 8:33 am
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

Re: Change Certificate in Application

Posted: Sun Sep 22, 2019 2:40 pm
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

Re: Change Certificate in Application

Posted: Wed Jun 16, 2021 4:27 pm
by darkducke
How to show the window for the user to select the certificate and get its index?

Re: Change Certificate in Application

Posted: Sat Jun 19, 2021 9:43 am
by salvadordf
This answer has all the code you need :
https://stackoverflow.com/questions/68006898/cef4delphi-certificate-selection-window