Подписание XML для отправки в ШЭП
==================================================================================================
.. code-block:: lua
output = {}
local pkgxml=require("pkg/xml")
local crypto=require('pkg/crypto')
ers,ern=crypto.LoadKey("/opt/damu/keys/GOSTKNCA_*****************.p12","**********")
local request_uuid = UUID()
local body = [[
00000000-9228-4bf4-8880-72280e728e92
GBDFL_UniversalServiceSync
2022-02-07T15:13:33.159+06:00
*****
*****
00000000000
123456789
2016-12-06T00:00:00.000+06:00
DAMUBPM
]]
local data = [[
]]
..body..
[[]]
local dsNS={ds="http://www.w3.org/2000/09/xmldsig#"}
local soapNS={soapenv="http://schemas.xmlsoap.org/soap/envelope/"}
local soapheader,container,ers,ern=pkgxml.ExtractXml(data,soapNS,'//soapenv:Header') --remove header
if ern~=0 then output = "ERR1"..ers..debug.traceback() return end
local signedData,ers,ern=crypto.SignXml(container,'',request_uuid)
if ern~=0 then output = "ERR2"..ers..debug.traceback() return end
local certInfo,ers,ern = crypto.GetCertFromXml(signedData)
if ern~=0 then output = "ERR3"..ers..debug.traceback() return end
local xmlsign,container,ers,ern=pkgxml.ExtractXml(signedData,dsNS,'//ds:Signature')
if ern~=0 then output = "ERR4"..ers..debug.traceback() return end
xmlsign,ers,ern=pkgxml.SetAttr(xmlsign,dsNS,'//ds:Signature',"Id",'ptpsign')
if ern~=0 then output = "ERR5"..ers..debug.traceback() return end
data,ers,ern=pkgxml.InsertXml(data,soapNS,'//soapenv:Header',xmlsign)
if ern~=0 then output = "ERR6"..ers..debug.traceback() return end
output=data
Подписание тела запроса:
.. code-block:: lua
output = {}
local crypto=require('pkg/crypto')
ers,ern=crypto.LoadKey("/opt/damu/keys/GOSTKNCA_************.p12","*********")
local xmlReqIn=[[00000000000000000000000]]
output,aa,a=crypto.SignXml( xmlReqIn ,"")