Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on ComputeSignature when changing from SHA256 to SHA1 #24173

Closed
Cae2 opened this issue Nov 19, 2017 · 2 comments
Closed

Error on ComputeSignature when changing from SHA256 to SHA1 #24173

Cae2 opened this issue Nov 19, 2017 · 2 comments
Milestone

Comments

@Cae2
Copy link

Cae2 commented Nov 19, 2017

Hello,
I need to use a service who still dont accept SHA256 Algorithm.

the following works when I execute:

var docXml = new SignedXml(xml);
...
docXml.SignedInfo.SignatureMethod = "http://www.w3.org/2000/09/xmldsig#rsa-sha1";
docXml.ComputeSignature();

but the Xml Reference stills in SHA256. If I change the Reference to also use SHA1 with:

var refer = new Reference { Uri = "xxxxx" };
...
refer.DigestMethod = "http://www.w3.org/2000/09/xmldsig#rsa-sha1";

the ComputeSignature() shows the error:

Exception has occurred: CLR/System.Security.Cryptography.CryptographicException
An exception of type 'System.Security.Cryptography.CryptographicException' occurred in >System.Security.Cryptography.Xml.dll but was not handled in user code: 'Could not create hash >algorithm object.'

can someone give me some advices to change all algorithms in that xml signature to SHA1?

thanks!

Edit:
ops, forgot to mention that I'm using ASP.NET Core 2.0, also tried with the last
System.Security.Cryptography.Xml 4.5.0-preview1-25914-04

@Cae2
Copy link
Author

Cae2 commented Nov 19, 2017

solved, I was using a wrong algorithm

changed:

refer.DigestMethod = "http://www.w3.org/2000/09/xmldsig#rsa-sha1";
for
refer.DigestMethod = SignedXml.XmlDsigSHA1Url;

@Cae2 Cae2 closed this as completed Nov 19, 2017
@leofonsilva
Copy link

solved, I was using a wrong algorithm

changed:

refer.DigestMethod = "http://www.w3.org/2000/09/xmldsig#rsa-sha1";
for
refer.DigestMethod = SignedXml.XmlDsigSHA1Url;

Hello, I would like to know how you created your signature class, because I tried everything, did what you said and did not work, I can not sign xml using SHA1 in Core

@msftgits msftgits transferred this issue from dotnet/corefx Jan 31, 2020
@msftgits msftgits added this to the 2.1.0 milestone Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants