我遵循了Microsoft的示例:https://docs.microsoft.com/en-us/dotnet/standard/security/how-to-sign-xml-documents-with-digital-signatures
我得到了签名。
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
<CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" />
<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
<Reference URI="">
<Transforms>
<Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
</Transforms>
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
<DigestValue>e7jQRU4xmLaQmWVO9pVovhWSeGU=</DigestValue>
</Reference>
</SignedInfo>
<SignatureValue>gAuVoU7bBgzJCD7VZku1Gvju4h/R4mQZGEXK5BoIAKbmYJqeWCYAdvb07gVwaFOc6DeQPmV3lS0BGE4wOZkNqvLqN2BhIM98hYSwd1KZgBDzkrNs6GoLmDLiJVwC+rq2IYOKfQumk3sD7V7KBZ/92/dbXPfPUOLEQRmF9tkJZBA=</SignatureValue>
</Signature>
但这并不是我需要的格式。我需要发送这样的数字签名:
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
<CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"></CanonicalizationMethod>
<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"></SignatureMethod>
<Reference URI="">
<Transforms>
<Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"></Transform>
</Transforms>
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></DigestMethod>
<DigestValue>e7jQRU4xmLaQmWVO9pVovhWSeGU=</DigestValue>
</Reference>
</SignedInfo>
<SignatureValue>gAuVoU7bBgzJCD7VZku1Gvju4h/R4mQZGEXK5BoIAKbmYJqeWCYAdvb07gVwaFOc6DeQPmV3lS0BGE4wOZkNqvLqN2BhIM98hYSwd1KZgBDzkrNs6GoLmDLiJVwC+rq2IYOKfQumk3sD7V7KBZ/92/dbXPfPUOLEQRmF9tkJZBA=</SignatureValue>
</Signature>
在此处注意结束标记。有什么方法可以指示xmlDigitalSignature组件吐出我需要的xml吗?