首页 > 解决方案 > 尝试在命令行中使用 XmlSec 对 XML 进行签名,不断收到“丢失文件错误”?

问题描述

无论我使用哪种命令顺序,我都会不断收到类似的错误消息:

xmlsec --sign --output signedfile.xml --pkcs FISKAL.p12 --pwd Password --trusted-pem root_ca.pem --id-attr:Id file.xml

我明白了

Error: ⟨file⟩ parameter is required for this command

如果我尝试

xmlsec --sign --id-attr:Id --pkcs FISKAL.p12 --pwd Password --trusted-pem root_ca.pem --output signedfile.xml file.xml

我明白了

Error: filename is expected instead of parameter "--pwd".
Error: invalid parameters

在这种情况下

xmlsec --sign --output signedfile.xml --id-attr:Id --trusted-pem root_ca.pem --pkcs FISKAL.p12 --pwd Password file.xml

它是相似的:

Error: filename is expected instead of parameter "--pkcs12".
Error: invalid parameters

每条错误消息下方是一行:Usage: xmlsec ⟨command⟩ [⟨options⟩] [⟨files⟩]

为什么 xmlsec 一直认为我缺少文件?我究竟做错了什么?

标签: xmlfilecommand-linedigital-signaturexmlsec

解决方案


您的--id-attr:Id参数不完整。要么删除它,要么你需要像这样指定它:

   --id-attr[:<attr-name>] [<node-namespace-uri>:]<node-name>

          adds attributes <attr-name> (default value "id") from all  nodes
          with<node-name>  and  namespace <node-namespace-uri> to the list
          of known ID attributes; this is a hack and if you can use DTD or
          schema  to  declare  ID  attributes  instead  (see  "--dtd-file"
          option), I don't know what else might be broken in your applica‐
          tion when you use this hack

node-name您需要指定,因为它不是可选的。您确实指定attr-name了,但它是可选的。这可能不是你想要的。


推荐阅读