Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
|
Verify SSL Server CertificateDemonstrates how to connect to an SSL server and verify its SSL certificate.
CREATE PROCEDURE ChilkatSample AS BEGIN DECLARE @hr int DECLARE @sTmp0 nvarchar(4000) DECLARE @socket int EXEC @hr = sp_OACreate 'Chilkat.Socket', @socket OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END DECLARE @success int EXEC sp_OAMethod @socket, 'UnlockComponent', @success OUT, 'Anything for 30-day trial' IF @success <> 1 BEGIN PRINT 'Failed to unlock component' RETURN END DECLARE @ssl int SELECT @ssl = 1 DECLARE @maxWaitMillisec int SELECT @maxWaitMillisec = 20000 -- The SSL server hostname may be an IP address, a domain name, -- or "localhost". DECLARE @sslServerHost nvarchar(4000) SELECT @sslServerHost = 'www.paypal.com' DECLARE @sslServerPort int SELECT @sslServerPort = 443 -- Connect to the SSL server: EXEC sp_OAMethod @socket, 'Connect', @success OUT, @sslServerHost, @sslServerPort, @ssl, @maxWaitMillisec IF @success <> 1 BEGIN EXEC sp_OAGetProperty @socket, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 RETURN END DECLARE @cert int DECLARE @bExpired int DECLARE @bRevoked int DECLARE @bSignatureVerified int DECLARE @bTrustedRoot int EXEC sp_OAMethod @socket, 'GetSslServerCert', @cert OUT IF Not (@cert Is NULL ) BEGIN PRINT 'Server Certificate:' EXEC sp_OAGetProperty @cert, 'SubjectDN', @sTmp0 OUT PRINT 'Distinguished Name: ' + @sTmp0 EXEC sp_OAGetProperty @cert, 'SubjectCN', @sTmp0 OUT PRINT 'Common Name: ' + @sTmp0 EXEC sp_OAGetProperty @cert, 'IssuerDN', @sTmp0 OUT PRINT 'Issuer Distinguished Name: ' + @sTmp0 EXEC sp_OAGetProperty @cert, 'IssuerCN', @sTmp0 OUT PRINT 'Issuer Common Name: ' + @sTmp0 EXEC sp_OAMethod @cert, 'IsExpired', @bExpired OUT EXEC sp_OAGetProperty @cert, 'Revoked', @bRevoked OUT EXEC sp_OAGetProperty @cert, 'SignatureVerified', @bSignatureVerified OUT EXEC sp_OAGetProperty @cert, 'TrustedRoot', @bTrustedRoot OUT PRINT 'Expired: ' + @bExpired PRINT 'Revoked: ' + @bRevoked PRINT 'Signature Verified: ' + @bSignatureVerified PRINT 'Trusted Root: ' + @bTrustedRoot END -- Close the connection with the server -- Wait a max of 20 seconds (20000 millsec) EXEC sp_OAMethod @socket, 'Close', NULL, 20000 END GO |
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.