xmldsigjs icon indicating copy to clipboard operation
xmldsigjs copied to clipboard

XML error

Open Hellomik2002 opened this issue 5 years ago • 1 comments
trafficstars

I installed webcrypto with npm by but still have issue when I try new XmlDSigJs.SignedXml().Sign(...)

XmlError {
  prefix: 'XMLJS',
  code: 14,
  name: 'XmlError',
  message: 'XMLJS0014: WebCrypto module is not found',
  stack: 'Error: XMLJS0014: WebCrypto module is not found\n' +
    '    at new XmlError (C:\\projects\\notr\\node_modules\\xml-core\\dist\\index.js:216:22)\n' +
    '    at Function.get crypto [as crypto] (C:\\projects\\notr\\node_modules\\xmldsigjs\\build\\index.js:22:19)\n' +
    '    at RsaKeyValue.importKey (C:\\projects\\notr\\node_modules\\xmldsigjs\\build\\index.js:1539:39)\n' +
    '    at KeyValue.importKey (C:\\projects\\notr\\node_modules\\xmldsigjs\\build\\index.js:1710:34)\n' +
    '    at SignedXml.ApplySignOptions (C:\\projects\\notr\\node_modules\\xmldsigjs\\build\\index.js:2656:28)\n' +
    '    at SignedXml.Sign (C:\\projects\\notr\\node_modules\\xmldsigjs\\build\\index.js:2360:20)\n' +
    '    at C:\\projects\\notr\\cryptXML.js:59:22'
}

Hellomik2002 avatar Jul 08 '20 12:07 Hellomik2002

You might have fallen into the same trap I did a while ago. First, if you do npm install webcrypto it doesn't provide WebCrypto. Then, the 3 libraries that do are listed in this post by me and I think the only one that works with xmldsigjs is webcrypto-ossl. (That post has now other libraries failed to work with xmldsigjs.) Even worse, these libraries have different initialisation methods so one can't serve as the drop-in replacement of another without tweak.

SmartLayer avatar Jul 08 '20 14:07 SmartLayer