Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Verify SSL Server CertificateDemonstrates how to connect to an SSL server and verify its SSL certificate.
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, CHILKATCERTIFICATELib_TLB, CHILKATSOCKETLib_TLB, OleCtrls; ... procedure TForm1.Button1Click(Sender: TObject); var socket: TChilkatSocket; success: Integer; ssl: Integer; maxWaitMillisec: Integer; sslServerHost: String; sslServerPort: Integer; cert: CHILKATSOCKETLib_TLB.IChilkatCert; bExpired: Integer; bRevoked: Integer; bSignatureVerified: Integer; bTrustedRoot: Integer; begin socket := TChilkatSocket.Create(Self); success := socket.UnlockComponent('Anything for 30-day trial'); if (success <> 1) then begin ShowMessage('Failed to unlock component'); end; ssl := 1; 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 := socket.Connect(sslServerHost,sslServerPort,ssl,maxWaitMillisec); if (success <> 1) then begin ShowMessage(socket.LastErrorText); end; cert := socket.GetSslServerCert() As CHILKATSOCKETLib_TLB.IChilkatCert; if (not (cert = nil )) then begin Memo1.Lines.Add('Server Certificate:'); Memo1.Lines.Add('Distinguished Name: ' + cert.SubjectDN); Memo1.Lines.Add('Common Name: ' + cert.SubjectCN); Memo1.Lines.Add('Issuer Distinguished Name: ' + cert.IssuerDN); Memo1.Lines.Add('Issuer Common Name: ' + cert.IssuerCN); bExpired := cert.IsExpired(); bRevoked := cert.Revoked; bSignatureVerified := cert.SignatureVerified; bTrustedRoot := cert.TrustedRoot; Memo1.Lines.Add('Expired: ' + IntToStr(bExpired)); Memo1.Lines.Add('Revoked: ' + IntToStr(bRevoked)); Memo1.Lines.Add('Signature Verified: ' + IntToStr(bSignatureVerified)); Memo1.Lines.Add('Trusted Root: ' + IntToStr(bTrustedRoot)); end; // Close the connection with the server // Wait a max of 20 seconds (20000 millsec) socket.Close(20000); end; |
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2008 Chilkat Software, Inc. All Rights Reserved.