//public async Task<ActionResult<List<X509Certificate2>>> VerifyXmlFile([FromForm]IFormFile xmlFile) public async Task <ActionResult <List <CertificateModel> > > VerifyXmlFileAndGetCertificates([FromForm] IFormFile xmlFile) { if (xmlFile.Length > 0) { XmlDocument xmlDocument = new XmlDocument(); try { string xmlString = await Adapter.ReadAsStringAsync(xmlFile); xmlDocument.LoadXml(xmlString); bool isSignatureVerified = false; XmlVerifierService verService = new XmlVerifierService(_config); List <CertificateModel> certList = await verService.GetAllSignedCertificateAsync(xmlString); if (isSignatureVerified) { return(certList); } else { return(BadRequest("Uploaded file has no sign")); } } catch (Exception ex) { return(BadRequest("The file is compromised - " + ex.ToString())); } } else { return(BadRequest("A file Should be Uploaded")); } }
internal async Task <bool> VerifyXmlWithServiceAsync() { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(XmlFile.FileContent); XmlVerifierService xmlVerService = new XmlVerifierService(_config); CertificateList = await xmlVerService.GetAllSignedCertificateAsync(xmlDoc.OuterXml); return(true); }