【签名加解密】c# 对XML进行数字签名并且让java验签成功

实现:

1.c#将xml报文做数字签名发送到java服务,java服务成功验签。

2.c#服务对收到java服务推送的xml报文成功验签。

前提:

1.java服务要求


遇到问题:

1.Java和.net 之前 RSA 私钥秘钥格式问题。

2.framework4.0 SignatureDescription could not be created for the signature algorithm supplied.  

无法为所提供的签名算法创建SignatureDescription。——资料6 第二个链接,关键在:在全局文件中,对加密配置(CryptoConfig)添加算法 RsaPkcs1Sha256SignatureDescription

3.


资料:

1.msdn:xml签名:https://docs.microsoft.com/zh-cn/dotnet/standard/security/how-to-sign-xml-documents-with-digital-signatures

2.msdn:xml验签:https://docs.microsoft.com/zh-cn/dotnet/standard/security/how-to-verify-the-digital-signatures-of-xml-documents

3.csdn讨论帖:https://bbs.csdn.net/topics/392005202

4.C#下解析、生成JAVA的RSA密钥、公钥:https://blog.csdn.net/starfd/article/details/51838589

5.微软对xml加签验签的举例:https://docs.microsoft.com/zh-cn/dotnet/api/system.security.cryptography.xml.signedxml?view=netframework-4.7.2

6.stack overflow对xml sha256签名的讨论帖:

    1). https://stackoverflow.com/questions/17258800/c-sharp-support-for-rsa-sha-256-signing-for-individual-xml-elements

    2). http://www.voidcn.com/article/p-ezohxnnk-bty.html

原文地址:https://www.cnblogs.com/heweiquan123/p/10163703.html