I try to use a certificate from the certificate store on Windows for za SOAP service, but it always ask for a certificate with a displayed dialog.
My code:
...
var RIO := THTTPRIO.Create(nil);
RIO.HTTPWebNode.HTTP.OnNeedClientCertificate := DoOnClientCertificateNeeded;
RIO.HTTPWebNode.GetHTTPReqResp.PreemptiveAuthentication := true;
var svc := wsETurizemPorocanje.GetrnoSoap(false, '', RIO);
data := TXmlData.Create;
data.LoadFromXml(xml.XML);
var errors := svc.oddajPorocilo('UserName', 'Password', data , 1);
...
end;
procedure TeTurizem.DoOnClientCertificateNeeded(const Sender: TObject; const ARequest: TURLRequest; const ACertificateList: TCertificateList; var AnIndex: Integer);
begin
for var idx := 0 to ACertificateList.Count - 1 do begin
if ACertificateList[idx].SerialNum = AppSettings.Server.Hostel.ETurizemSettings.CertSerial then begin
if (ACertificateList[idx].Start<=Now) and (ACertificateList[idx].Expiry>Now) then begin
AnIndex := idx;
break;
end else
raise Exception.Create('(DoOnClientCertificateNeeded) Client Certificate Expired.');
end;
end;
end;
I’m going nuts, because I can’t find a lot of documentation or examples.
What do I need to provide the SOAP call a certificate from the cert store? Isn’t defining the event enough?
New contributor
Marko Milutinović is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.