I am trying a verify a XAdES signature that I have created using XadesNetLib from codeplex.
I have implemented detached signature and hence the signature refers to an XML file defined in the URI attribute of Reference tag. Though, both the signature file and the XML are located in the same folder. I am getting an error "Unable to resolve Uri" while trying to verify the signature using the code below
private static VerificationResults PerformValidationFromXml(string xml, VerificationParameters validationParameters)
{
var document = new XmlDocument { PreserveWhitespace = false };
document.LoadXml(xml);
var newsignedXml = new ExtendedSignedXml(document);
if (document.DocumentElement == null) throw new InvalidDocumentException("Document has no root element");
var signatureNode = XmlDsigNodesHelper.GetSignatureNode(document);
newsignedXml.LoadXml(signatureNode);
var verificationCertificate = GetVerificationCertificate(newsignedXml, validationParameters);
if (verificationCertificate == null) throw new Exception("Signer public key could not be found");
if (!newsignedXml.CheckSignature(verificationCertificate, !validationParameters.VerifyCertificate))
{
throw new InvalidOperationException("Signature is invalid.");
}
var results = new VerificationResults
{
Timestamp = GetTimeStampFromSignature(document),
OriginalDocument = GetDocumentFromSignature(document),
SigningCertificate = GetCertificateFromSignature(document)
};
return results;
}
Any help is much appreciated!