![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(SQL Server) Sign XML (XAdES) in the Cloud using AWS KMSSee more Signing in the Cloud ExamplesDemonstrates how to sign XML using AWS KMS. The signing of the hash happens in AWK KMS. Everything else involving the updating the XML to add the signature happens locally within Chilkat.Note: This example requires Chilkat v9.5.0.96 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 -- 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. -- Create the XML to be signed. DECLARE @sbXml int -- Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbXml OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END DECLARE @bCrlf int SELECT @bCrlf = 1 DECLARE @success int EXEC sp_OAMethod @sbXml, 'AppendLine', @success OUT, '<?xml version="1.0" encoding="UTF-8" standalone="no" ?>', @bCrlf EXEC sp_OAMethod @sbXml, 'AppendLine', @success OUT, '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">', @bCrlf EXEC sp_OAMethod @sbXml, 'AppendLine', @success OUT, ' <SOAP-ENV:Header>', @bCrlf EXEC sp_OAMethod @sbXml, 'AppendLine', @success OUT, ' <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" SOAP-ENV:mustUnderstand="1"></wsse:Security>', @bCrlf EXEC sp_OAMethod @sbXml, 'AppendLine', @success OUT, ' </SOAP-ENV:Header>', @bCrlf EXEC sp_OAMethod @sbXml, 'AppendLine', @success OUT, ' <SOAP-ENV:Body xmlns:SOAP-SEC="http://schemas.xmlsoap.org/soap/security/2000-12" SOAP-SEC:id="Body">', @bCrlf EXEC sp_OAMethod @sbXml, 'AppendLine', @success OUT, ' <z:FooBar xmlns:z="http://example.com" />', @bCrlf EXEC sp_OAMethod @sbXml, 'AppendLine', @success OUT, ' </SOAP-ENV:Body>', @bCrlf EXEC sp_OAMethod @sbXml, 'AppendLine', @success OUT, '</SOAP-ENV:Envelope>', @bCrlf -- Load the certificate used for signing. The certificate's private key is stored in AWS KMS -- However, we still need the certificate locally (without private key). DECLARE @cert int -- Use "Chilkat_9_5_0.Cert" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.Cert', @cert OUT DECLARE @success int EXEC sp_OAMethod @cert, 'LoadFromFile', @success OUT, 'qa_data/certs/myCert.cer' IF @success = 0 BEGIN EXEC sp_OAGetProperty @cert, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 EXEC @hr = sp_OADestroy @sbXml EXEC @hr = sp_OADestroy @cert RETURN END -- Here's a screenshot of our private key AWS KMS: |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.