Sample code for 30+ languages & platforms
Delphi DLL Requires Chilkat v11.0.0+

Transition from Http.GetServerSslCert to Http.GetServerCert

See more HTTP Examples

Provides instructions for replacing deprecated GetServerSslCert method calls with GetServerCert.

Chilkat Delphi DLL Downloads

Delphi DLL
var
success: Boolean;
http: HCkHttp;
domain: PWideChar;
port: Integer;
cert1: HCkCert;
cert2: HCkCert;

begin
success := False;

http := CkHttp_Create();
domain := 'chilkatsoft.com';
port := 443;

//  ------------------------------------------------------------------------
//  The GetServerSslCert method is deprecated:

cert1 := CkHttp_GetServerSslCert(http,domain,port);
if (CkHttp_getLastMethodSuccess(http) = False) then
  begin
    Memo1.Lines.Add(CkHttp__lastErrorText(http));
    Exit;
  end;
Memo1.Lines.Add(CkCert__subjectDN(cert1));
CkCert_Dispose(cert1);

//  ------------------------------------------------------------------------
//  Do the equivalent using GetServerCert.
//  Your application creates a new, empty certificate object which is passed 
//  in the last argument and filled with the server certificate upon success.

cert2 := CkCert_Create();
success := CkHttp_GetServerCert(http,domain,port,cert2);
if (success = False) then
  begin
    Memo1.Lines.Add(CkHttp__lastErrorText(http));
    Exit;
  end;
Memo1.Lines.Add(CkCert__subjectDN(cert2));

CkHttp_Dispose(http);
CkCert_Dispose(cert2);