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) ZATCA Load Certificate and Private Key from PEM FilesSee more ZATCA ExamplesDemonstrates how to load a certificate and private key from a pair of PEM files.
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls. -- CREATE PROCEDURE ChilkatSample AS BEGIN DECLARE @hr int -- Important: Do not use nvarchar(max). See the warning about using nvarchar(max). DECLARE @sTmp0 nvarchar(4000) -- The LoadFromFile method will automatically detect the file format.. DECLARE @cert int -- Use "Chilkat_9_5_0.Cert" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.Cert', @cert OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END DECLARE @success int EXEC sp_OAMethod @cert, 'LoadFromFile', @success OUT, 'qa_data/zatca/cert.pem' IF @success <> 1 BEGIN EXEC sp_OAGetProperty @cert, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 EXEC @hr = sp_OADestroy @cert RETURN END EXEC sp_OAGetProperty @cert, 'SubjectCN', @sTmp0 OUT PRINT @sTmp0 -- Load the private key. DECLARE @privKey int -- Use "Chilkat_9_5_0.PrivateKey" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.PrivateKey', @privKey OUT EXEC sp_OAMethod @privKey, 'LoadPemFile', @success OUT, 'qa_data/zatca/ec-secp256k1-priv-key.pem' IF @success <> 1 BEGIN EXEC sp_OAGetProperty @privKey, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 EXEC @hr = sp_OADestroy @cert EXEC @hr = sp_OADestroy @privKey RETURN END EXEC sp_OAGetProperty @privKey, 'KeyType', @sTmp0 OUT PRINT 'Key Type: ' + @sTmp0 -- Associate the private key with the certificate. EXEC sp_OAMethod @cert, 'SetPrivateKey', @success OUT, @privKey IF @success <> 1 BEGIN EXEC sp_OAGetProperty @cert, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 EXEC @hr = sp_OADestroy @cert EXEC @hr = sp_OADestroy @privKey RETURN END PRINT 'Success.' EXEC @hr = sp_OADestroy @cert EXEC @hr = sp_OADestroy @privKey END GO |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.