I'm doing about verifying digital signature. And when I was trying to use SignedCms.Decode()
, it caused System.Security.Cryptography.CryptographicException
{"ASN1 bad tag value
met.\r\n"}
I generate the signature data in Java, and try to verify it in C#.
Here is C# code for verifying signature.
//base64 signature data
string encodedMessage_b64 = "ahXwmjFNUVxxxxxx==";
byte[] encodedMessage = Convert.FromBase64String(encodedMessage_b64);
SignedCms signedCms = new SignedCms();
//throw exception
signedCms.Decode(encodedMessage);
And here is Java code for generating signature.
Signature rsaSig = Signature.getInstance("SHA1withRSA");
//privateKey from keytore
rsaSig.initSign(priKey);
rsaSig.update(data.getBytes());
//org.apache.commons.codec.binary.Base64;
String signedData = Base64.encodeBase64String(rsaSig.sign());
The problem is carriage return
and line feed
, I don't know where they come from.
Any advice would be greatly appreciated :)