SSLClient connect to Website via Certificate
Posted: Thu 17 Nov 2016 14:18
Hi guys,
I try to connect to a website with sub directories and has to use a certifcate for authentication.
This function seems to work.
but if I change the Host to www.examples.com/test it throws an exception.
Is there any possibility to use subdirectories?
Thank you.
I try to connect to a website with sub directories and has to use a certifcate for authentication.
This function seems to work.
but if I change the Host to www.examples.com/test it throws an exception.
Is there any possibility to use subdirectories?
Code: Select all
procedure TForm3.btn1Click(Sender: TObject);
var
cert : TScCertificate;
storage : TScFileStorage;
client : TScSSLClient;
i : Integer;
b : boolean;
certName : String;
ciphers:TScSSLCipherSuites;
begin
storage := TScFileStorage.Create(Self);
client := TScSSLClient.Create(Self);
try
client.HostName := 'www.examples.com';
client.Port := 443;
storage.Path := 'C:\Certs\';
certName := 'cert.cer';
b := False;
for i := 0 to storage.Certificates.Count - 1 do begin
cert := storage.Certificates[i];
if (cert.CertName = certName) then begin
b := True;
end;
end;
if (not b) then begin
cert := TScCertificate.Create(storage.Certificates);
cert.CertName := CertName;
cert.ImportFrom(CertName);
cert.Ready := True;
end;
client.Storage := storage;
client.Connect;
if (client.Connected) then begin
client.IsSecure := True;
ShowMessage ('Connected');
end;
except
on E:Exception do begin
ShowMessage (e.Message);
end;
end;
client.Disconnect;
client.Free;
storage.Free;
end;