You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
First of all I would like to apologize if my issue is redundant, I am not very experienced in xml signatures.
I would like to sign my document with only enveloped-signature as transform
I have based my code on #93 solution
I use this function to sign
const forge = require('node-forge'),
pki = forge.pki,
select = require('xml-crypto').xpath
, dom = require('xmldom').DOMParser
, SignedXml = require('xml-crypto').SignedXml
, FileKeyInfo = require('xml-crypto').FileKeyInfo
, fs = require('fs');
function signXML(){
let sig = new SignedXml()
sig.addReference("//*[local-name(.)='elmo']",[
'http://www.w3.org/2000/09/xmldsig#enveloped-signature',]
//'http://www.w3.org/TR/2001/REC-xml-c14n-20010315'
,'http://www.w3.org/2001/04/xmlenc#sha256',"","","",true)
sig.signingKey = RSA_key
sig.keyInfoProvider = new KeyInfoProvider(RSA_cert)
sig.canonicalizationAlgorithm = 'http://www.w3.org/TR/2001/REC-xml-c14n-20010315';
sig.signatureAlgorithm = "http://www.w3.org/2000/09/xmldsig#rsa-sha1";
sig.computeSignature(xml )
fs.writeFileSync("signed.xml", sig.getSignedXml())
}
// and this to validate the signed xml
function testValidate(){
var xml = fs.readFileSync("signed.xml").toString()
var doc = new dom().parseFromString(xml)
var signature = select(doc, "//*[local-name(.)='Signature' and namespace-uri(.)='http://www.w3.org/2000/09/xmldsig#']")
var sig = new SignedXml()
sig.keyInfoProvider = new KeyInfoProvider(fs.readFileSync("client_public.pem"))
sig.loadSignature(signature[0].toString())
var res = sig.checkSignature(xml)
if (!res) console.log(sig.validationErrors)
console.log(res);
return res
}
It shouldn't be relevant I am have taken this from another issue #47 to create the X509Data
Off hand, I don't know if what you're asking for is possible, but if you created a PR with a test that fails that clearly shows what you're after, it will speed up the process of getting a fix and will ensure that the feature/fix that you're after stays working. @Flyingpeanut , @HariAmbadi , @clucher91 or @iaguedo would any of you be willing to do that?
Hi,
First of all I would like to apologize if my issue is redundant, I am not very experienced in xml signatures.
I would like to sign my document with only enveloped-signature as transform
I have based my code on #93 solution
I use this function to sign
It shouldn't be relevant I am have taken this from another issue #47 to create the X509Data
, but when I run with REC-xml-c14n-20010315 transform everything is ok
but when I remove it from the transforms I get this error:
It it possible to make signature with only enveloped signature as transform?
The text was updated successfully, but these errors were encountered: