We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hello, I've used this library to verify XMLDSIG created by CryptoPro, the main problem was that I needed to extract public key manually. Example:
public static bool VerifyXMLDSIG(string xmldsigFilename) { if (xmldsigFilename == null) throw new ArgumentNullException(nameof(xmldsigFilename)); var xmlDocument = new XmlDocument(); xmlDocument.PreserveWhitespace = true; xmlDocument.Load(xmldsigFilename); var signedXml = new SignedXml(xmlDocument); var signatureElement = xmlDocument.GetElementsByTagName("Signature", SignedXml.XmlDsigNamespaceUrl)[0] as XmlElement; signedXml.LoadXml(signatureElement); var isValidXml = false; if (signedXml.KeyInfo != null) { foreach (KeyInfoClause clause in signedXml.KeyInfo) { if (isValidXml) break; if (clause is KeyInfoX509Data x509Data) { foreach(X509Certificate2 cert in x509Data.Certificates) { if (isValidXml) break; var oid = cert.PublicKey.EncodedParameters.Oid; var key = default(AsymmetricAlgorithm); if (oid.Value == "1.2.643.7.1.1.1.1" || oid.Value == "1.2.643.7.1.1.1.2") { key = cert.GetGostECDsaPublicKey(); } else { key = cert.GetECDsaPublicKey(); } if (key != null) { isValidXml = signedXml.CheckSignature(key); key.Dispose(); key = null; } } } } } return isValidXml; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hello, I've used this library to verify XMLDSIG created by CryptoPro, the main problem was that I needed to extract public key manually. Example:
The text was updated successfully, but these errors were encountered: