如何使用数字签名对XML进行签名?

时间:2019-11-18 03:59:59

标签: html xml digital-signature xml-signature

我需要对以下XML代码进行签名,但是我不知道如何计算“ DigestValue”或“ SignatureValue”。可以使用Java或JavaScript吗?

有人可以帮我吗?

<Body wsu:Id="id-1">
  <ns5:upload xmlns:ns4="http://msa.ebs.health.ontario.ca/" xmlns:ns3="http://idp.ebs.health.ontario.ca/" xmlns:ns2="http://ebs.health.ontario.ca/" xmlns:ns5="http://edt.health.ontario.ca/">
    <upload>
      <content> AAAA</content>
      <description>Demo</description>
      <resourceType>CL</resourceType>
    </upload>
  </ns5:upload>
</Body>

<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Id="SIG-6">
  <ds:SignedInfo>
    <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
      <ec:InclusiveNamespaces xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#" PrefixList="SOAP-ENV               ebs soap-sec soapenv sp tns wsdl wsp wsse wsu xs xsi" />
    </ds:CanonicalizationMethod>
    <ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
    <ds:Reference URI="#id-1">
      <ds:Transforms>
        <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
          <ec:InclusiveNamespaces xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#" PrefixList="SOAP-ENV ebs soap-sec soapenv sp tns wsdl wsp wsse wsu xs xsi" />
        </ds:Transform>
      </ds:Transforms>
      <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" />
      <ds:DigestValue>FkhA37COGmsKeEH50LAGhKntvRpD0+xOGsGzXAV210k=</ds:DigestValue>
    </ds:Reference>
  </ds:SignedInfo>
  <ds:SignatureValue> HmOiZS4gZbxv07+sLjyi7Vfg3Rfpvr3IVnaHfRp4aKvg5yBFlLocPIYwhUhmCCs1LXrJxR0hsbe0K2sz3ML5hH+PDEGetlPKSN9R1x9 K95w7V 1JQcTUULiVgNGLCfxgFV2HNy1iNvlTc7COS+7w4xSgsY4KlVgrBw0T1srhHpUA=
  </ds:SignatureValue>
  <ds:KeyInfo Id="KI-0EE1C2718CEDCA9FC213407274954662">
    <wsse:SecurityTokenReference wsu:Id="STR-0EE1C2718CEDCA9FC213407274954663">
      <wsse:Reference URI="#X509-0EE1C2718CEDCA9FC213407274954261" ValueType="http://docs.oasis-                open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" />
    </wsse:SecurityTokenReference>
  </ds:KeyInfo>
</ds:Signature>

0 个答案:

没有答案