public ExCert[] GetCertificates() { CAdESCOM.CPStore store = new CAdESCOM.CPStore(); store.Open(); try { CAPICOM.ICertificates icerts = store.Certificates; ExCert[] certs = new ExCert[icerts.Count]; int i = 0; foreach (CAPICOM.Certificate cert in store.Certificates) { certs[i++] = new ExCert(cert); } return(certs); } finally { store.Close(); } }
/**/ public string GetIDFileFromTicket(string ticketContent, Event e) { if (e.soapFileName.Contains("DP_OTORG1_") || e.soapFileName.Contains("DP_OTORG2_")) { return(GetIDFileFromTicket(ticketContent, "UTF-8")); } else { return(GetIDFileFromTicket(ticketContent, "windows-1251")); } } public string GetIDFileFromTicket(string ticketContent) { return(GetIDFileFromTicket(ticketContent, "windows-1251")); } public string GetIDFileFromTicket(string ticketContent, string encoding) { try { string xmlString = Utils.Base64Decode(ticketContent, encoding); XmlDocument xml = new XmlDocument(); xml.LoadXml(xmlString); return(xml.SelectSingleNode("/Файл[@*]/@ИдФайл").InnerText + ".xml"); } catch (Exception e) { Logger.error(e.StackTrace); throw e; } } private string authorize() { string login = conf.Login; string password = conf.Api_pass; AuthorizeResponse response; try { response = (AuthorizeResponse)Http2.post <AuthorizeResponse>("https://api-service.edi.su/Api/Dixy/Index/Authorize", new AuthorizeRequest(login, password)); return(response.varToken); } catch (Exception ex) { Logger.log("ERROR: api auth fails. Api funcs will NOT be able . Reason : " + ex.Message); return(null); } } /**/ public ExCert GetExCertificate(string thumbprint) { CAdESCOM.CPStore store = new CAdESCOM.CPStore(); store.Open(); try { CAPICOM.ICertificates icerts = store.Certificates; ExCert[] certs = new ExCert[icerts.Count]; int i = 0; foreach (CAPICOM.Certificate cert in store.Certificates) { if (cert.Thumbprint.Equals(thumbprint) && cert.HasPrivateKey()) { return(new ExCert(cert)); } } throw new Exception("No certificate was found by thumbprint [" + thumbprint + "]"); } finally { store.Close(); } }