Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(SQL Server) Convert CRL PEM to XMLLoads a CRL (Certificate Revocation List) from the PEM file format and converts to XML to allow for visual examination and parsing. Note: This example requires Chilkat v9.5.0.77 or greater.
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls. -- CREATE PROCEDURE ChilkatSample AS BEGIN DECLARE @hr int DECLARE @iTmp0 int -- Important: Do not use nvarchar(max). See the warning about using nvarchar(max). DECLARE @sTmp0 nvarchar(4000) -- This example requires the Chilkat API to have been previously unlocked. -- See Global Unlock Sample for sample code. -- This example requires Chilkat v9.5.0.77 or greater. DECLARE @pem int -- Use "Chilkat_9_5_0.Pem" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.Pem', @pem OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END EXEC sp_OASetProperty @pem, 'VerboseLogging', 1 DECLARE @success int EXEC sp_OAMethod @pem, 'LoadPemFile', @success OUT, 'qa_data/crl/sampleCrl.pem', 'password_not_used' IF @success <> 1 BEGIN EXEC sp_OAGetProperty @pem, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 EXEC @hr = sp_OADestroy @pem RETURN END DECLARE @numCrls int EXEC sp_OAGetProperty @pem, 'NumCrls', @numCrls OUT DECLARE @i int SELECT @i = 0 DECLARE @asn int -- Use "Chilkat_9_5_0.Asn" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.Asn', @asn OUT DECLARE @xml int -- Use "Chilkat_9_5_0.Xml" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.Xml', @xml OUT WHILE @i < @numCrls BEGIN -- Get the CRL as base64 (multi-line) DECLARE @crlBase64 nvarchar(4000) EXEC sp_OAMethod @pem, 'GetEncodedItem', @crlBase64 OUT, 'crl', '', 'base64_mime', @i EXEC sp_OAGetProperty @pem, 'LastMethodSuccess', @iTmp0 OUT IF @iTmp0 <> 1 BEGIN EXEC sp_OAGetProperty @pem, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 EXEC @hr = sp_OADestroy @pem EXEC @hr = sp_OADestroy @asn EXEC @hr = sp_OADestroy @xml RETURN END PRINT @crlBase64 EXEC sp_OAMethod @asn, 'LoadEncoded', @success OUT, @crlBase64, 'base64' IF @success <> 1 BEGIN EXEC sp_OAGetProperty @asn, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 EXEC @hr = sp_OADestroy @pem EXEC @hr = sp_OADestroy @asn EXEC @hr = sp_OADestroy @xml RETURN END -- Convert ASN.1 to XML and load into xml and re-emit for pretty printing.. EXEC sp_OAMethod @asn, 'AsnToXml', @sTmp0 OUT EXEC sp_OAMethod @xml, 'LoadXml', @success OUT, @sTmp0 EXEC sp_OAMethod @xml, 'GetXml', @sTmp0 OUT PRINT @sTmp0 -- Use this online tool to generate parsing code from CRL XML: -- Generate Parsing Code from XML PRINT '-------------------------------------' SELECT @i = @i + 1 END EXEC @hr = sp_OADestroy @pem EXEC @hr = sp_OADestroy @asn EXEC @hr = sp_OADestroy @xml END GO |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.