SSLClient connect to Website via Certificate

Discussion of open issues, suggestions and bugs regarding network security and data protection solution - SecureBridge
Post Reply
Matze87
Posts: 1
Joined: Thu 17 Nov 2016 13:46

SSLClient connect to Website via Certificate

Post by Matze87 » 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?


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;
Thank you.

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: SSLClient connect to Website via Certificate

Post by ViktorV » Fri 18 Nov 2016 09:37

The TScSSLClient.HostName property must contain an IP address or a domain name of the server which we connect to.
TScSSLClient is not used for working with HTTP protocol. To solve your issue, you should specify a subdirectory when working with HTTP protocol.

Post Reply