public async Task LoadCertificates(OstcCertificateListType certList, OstcCertificateType certType) { var ostcClient = new OstcClient(Network.Base.Test); var certs = await ostcClient.DownloadCertificateListAsync(certList, certType); Assert.NotNull(certs); Assert.NotEqual(0, certs.Count); }
public async Task LoadCertificates(OstcCertificateListType certList, OstcCertificateType certType) { var restClient = new RestClient(Network.Base.Test); var ostcClient = new OstcClient(restClient, null); var certs = await ostcClient.DownloadCertificateListAsync(certList, certType); Assert.NotNull(certs); Assert.NotEqual(0, certs.Count); }
/// <summary> /// Zertifikat-Liste vom OSTC-Server laden /// </summary> /// <param name="listType">Art der Zertifikat-Liste</param> /// <param name="certType">Art des Zertifikats (SHA1 oder SHA256)</param> /// <returns>Liste der Zertifikate</returns> public async Task <IReadOnlyList <X509Certificate> > DownloadCertificateListAsync(OstcCertificateListType listType, OstcCertificateType certType) { Uri downloadUrl = null; switch (listType) { case OstcCertificateListType.Receiver: downloadUrl = new Uri("https://trustcenter-data.itsg.de/agv/annahme-sha256.agv"); break; case OstcCertificateListType.Complete: #pragma warning disable CS0618 // Typ oder Element ist veraltet if (certType == (OstcCertificateType.Sha1 | OstcCertificateType.Sha256)) #pragma warning restore CS0618 // Typ oder Element ist veraltet { // Mehr als nur SHA256 downloadUrl = new Uri("https://trustcenter-data.itsg.de/agv/gesamt-pkcs.agv"); } else { downloadUrl = new Uri("https://trustcenter-data.itsg.de/agv/gesamt-sha256.agv"); } break; } Debug.Assert(downloadUrl != null); var data = await DownloadAsync(downloadUrl); var allCerts = new List <X509Certificate>(); allCerts.AddRange(OstcUtils.ReadCertificates(new MemoryStream(data))); return(allCerts); }
/// <summary> /// Zertifikat-Liste vom OSTC-Server laden /// </summary> /// <param name="listType">Art der Zertifikat-Liste</param> /// <param name="certType">Art des Zertifikats (SHA1 oder SHA256)</param> /// <returns>Liste der Zertifikate</returns> public async Task<IReadOnlyList<X509Certificate>> DownloadCertificateListAsync(OstcCertificateListType listType, OstcCertificateType certType) { Uri downloadUrl = null; switch (listType) { case OstcCertificateListType.Receiver: if ((certType & OstcCertificateType.Sha1) == OstcCertificateType.Sha1) downloadUrl = new Uri("ftp://trustcenter-ftp.itsg.de/agv/annahme-pkcs.agv"); else if ((certType & OstcCertificateType.Sha256) == OstcCertificateType.Sha256) downloadUrl = new Uri("ftp://trustcenter-ftp.itsg.de/agv/annahme-sha256.agv"); break; case OstcCertificateListType.Complete: if (certType == (OstcCertificateType.Sha1 | OstcCertificateType.Sha256)) { downloadUrl = new Uri("ftp://trustcenter-ftp.itsg.de/agv/gesamt-pkcs.agv"); } else { if ((certType & OstcCertificateType.Sha1) == OstcCertificateType.Sha1) downloadUrl = new Uri("ftp://trustcenter-ftp.itsg.de/agv/gesamt-sha1.agv"); if ((certType & OstcCertificateType.Sha256) == OstcCertificateType.Sha256) downloadUrl = new Uri("ftp://trustcenter-ftp.itsg.de/agv/gesamt-sha256.agv"); } break; } Debug.Assert(downloadUrl != null); var data = await DownloadAsync(downloadUrl); var allCerts = new List<X509Certificate>(); allCerts.AddRange(OstcUtils.ReadCertificates(new MemoryStream(data))); return allCerts; }