示例#1
0
        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);
        }
示例#2
0
        public async Task LoadCrl(OstcCertificateType certType)
        {
            var ostcClient = new OstcClient(Network.Base.Test);
            var crl        = await ostcClient.DownloadCrlAsync(certType);

            Assert.NotNull(crl);
            var revokedCerts = crl.GetRevokedCertificates();

            Assert.NotEqual(0, revokedCerts.Count);
        }
示例#3
0
        /// <summary>
        /// Zertifikatsperrliste vom OSTC-Server laden
        /// </summary>
        /// <param name="certType">Art des Zertifikats (SHA1 oder SHA256)</param>
        /// <param name="preferFtp">FTP-Server-Download bevorzugen?</param>
        /// <returns>Zertifikatsperrliste</returns>
        public async Task <X509Crl> DownloadCrlAsync(OstcCertificateType certType, bool preferFtp = true)
        {
            Uri downloadUrl = new Uri("https://trustcenter-data.itsg.de/agv/sperrliste-ag-sha256.crl");

            Debug.Assert(downloadUrl != null);

            var data = await DownloadAsync(downloadUrl);

            var crlParser = new X509CrlParser();
            var crl       = crlParser.ReadCrl(data);

            return(crl);
        }
示例#4
0
        /// <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);
        }
示例#5
0
 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);
 }
示例#6
0
 public async Task LoadCrl(OstcCertificateType certType)
 {
     var restClient = new RestClient(Network.Base.Test);
     var ostcClient = new OstcClient(restClient, null);
     var crl = await ostcClient.DownloadCrlAsync(certType);
     Assert.NotNull(crl);
     var revokedCerts = crl.GetRevokedCertificates();
     Assert.NotEqual(0, revokedCerts.Count);
 }
示例#7
0
        /// <summary>
        /// Zertifikatsperrliste vom OSTC-Server laden
        /// </summary>
        /// <param name="certType">Art des Zertifikats (SHA1 oder SHA256)</param>
        /// <param name="preferFtp">FTP-Server-Download bevorzugen?</param>
        /// <returns>Zertifikatsperrliste</returns>
        public async Task<X509Crl> DownloadCrlAsync(OstcCertificateType certType, bool preferFtp = true)
        {
            Uri downloadUrl = null;
            if ((certType & OstcCertificateType.Sha1) == OstcCertificateType.Sha1)
                downloadUrl = new Uri("ftp://trustcenter-ftp.itsg.de/agv/sperrliste-ag.crl");
            else if ((certType & OstcCertificateType.Sha256) == OstcCertificateType.Sha256)
                downloadUrl = new Uri("ftp://trustcenter-ftp.itsg.de/agv/sperrliste-ag-sha256.crl");

            Debug.Assert(downloadUrl != null);

            var data = await DownloadAsync(downloadUrl);

            var crlParser = new X509CrlParser();
            var crl = crlParser.ReadCrl(data);

            return crl;
        }
示例#8
0
        /// <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;
        }