Delphi DLL Requires Chilkat v11.0.0+
Delphi DLL
Verify SSL Server Certificate
See more Socket/SSL/TLS Examples
Demonstrates how to connect to an SSL server and verify its SSL certificate.Chilkat Delphi DLL Downloads
var
success: Boolean;
socket: HCkSocket;
ssl: Boolean;
maxWaitMillisec: Integer;
sslServerHost: PWideChar;
sslServerPort: Integer;
cert: HCkCert;
bExpired: Boolean;
bRevoked: Boolean;
bSignatureVerified: Boolean;
bTrustedRoot: Boolean;
begin
success := False;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
socket := CkSocket_Create();
ssl := True;
maxWaitMillisec := 20000;
// The SSL server hostname may be an IP address, a domain name,
// or "localhost".
sslServerHost := 'www.paypal.com';
sslServerPort := 443;
// Connect to the SSL server:
success := CkSocket_Connect(socket,sslServerHost,sslServerPort,ssl,maxWaitMillisec);
if (success = False) then
begin
Memo1.Lines.Add(CkSocket__lastErrorText(socket));
Exit;
end;
cert := CkCert_Create();
success := CkSocket_GetServerCert(socket,cert);
if (success <> False) then
begin
Memo1.Lines.Add('Server Certificate:');
Memo1.Lines.Add('Distinguished Name: ' + CkCert__subjectDN(cert));
Memo1.Lines.Add('Common Name: ' + CkCert__subjectCN(cert));
Memo1.Lines.Add('Issuer Distinguished Name: ' + CkCert__issuerDN(cert));
Memo1.Lines.Add('Issuer Common Name: ' + CkCert__issuerCN(cert));
bExpired := CkCert_getExpired(cert);
bRevoked := CkCert_getRevoked(cert);
bSignatureVerified := CkCert_getSignatureVerified(cert);
bTrustedRoot := CkCert_getTrustedRoot(cert);
Memo1.Lines.Add('Expired: ' + IntToStr(Ord(bExpired)));
Memo1.Lines.Add('Revoked: ' + IntToStr(Ord(bRevoked)));
Memo1.Lines.Add('Signature Verified: ' + IntToStr(Ord(bSignatureVerified)));
Memo1.Lines.Add('Trusted Root: ' + IntToStr(Ord(bTrustedRoot)));
end;
// Close the connection with the server
// Wait a max of 20 seconds (20000 millsec)
success := CkSocket_Close(socket,20000);
CkSocket_Dispose(socket);
CkCert_Dispose(cert);