コード例 #1
0
 public async Task <X509CrlCollectionApiModel> GetCertificateGroupIssuerCACrlChainAsync(
     string group,
     string thumbPrint,
     [FromQuery] string nextPageLink,
     [FromQuery] int?pageSize)
 {
     return(new X509CrlCollectionApiModel(
                await _certificateGroups.GetIssuerCACrlChainAsync(group, thumbPrint, nextPageLink, pageSize)));
 }
コード例 #2
0
        public async Task <ActionResult> GetIssuerCrlAsync(string serial, string crl)
        {
            try
            {
                serial = serial.ToLower();
                crl    = crl.ToLower();
                if (crl.EndsWith(".crl"))
                {
                    string groupId = crl.Substring(0, crl.Length - 4);
                    // find isser cert with serial no.
                    X509Certificate2Collection certVersions;
                    string nextPageLink;
                    (certVersions, nextPageLink) = await _certificateGroups.GetIssuerCACertificateVersionsAsync(groupId, false);

                    while (certVersions != null && certVersions.Count > 0)
                    {
                        foreach (var cert in certVersions)
                        {
                            if (serial.Equals(cert.SerialNumber, StringComparison.OrdinalIgnoreCase))
                            {
                                var thumbPrint = cert.Thumbprint;
                                var crlBinary  = await _certificateGroups.GetIssuerCACrlChainAsync(groupId, thumbPrint);

                                var byteArray = crlBinary[0].RawData;
                                return(new FileContentResult(byteArray, ContentType.Crl)
                                {
                                    FileDownloadName = Utils.DownloadName(cert, groupId) + ".crl"
                                });
                            }
                        }
                        if (nextPageLink != null)
                        {
                            (certVersions, nextPageLink) = await _certificateGroups.GetIssuerCACertificateVersionsAsync(groupId, false, nextPageLink);
                        }
                        else
                        {
                            certVersions = null;
                        }
                    }
                }
            }
            catch
            {
                await Task.Delay(1000);
            }
            return(new NotFoundResult());
        }