Esempio n. 1
0
        private async Task ComposeChain(CertificateChainBuilder builder, X509Certificate2 x509, string url)
        {
            builder.AddItem(x509.ToPEM(), url);
            if (x509.IsRoot())
            {
                return;
            }

            var uri  = _uriFinder.Find(x509);
            var file = await DownloadCertificate(uri, x509);

            using (var signer = new X509Certificate2(file))
            {
                await ComposeChain(builder, signer, uri.ToString());
            }
        }
Esempio n. 2
0
        public async Task <CertificateChain> ComposeChain(string firstCertificateAsPem, string originalUrl = "http://localhost")
        {
            var builder = new CertificateChainBuilder();

            try
            {
                using (var x509 = new X509Certificate2(Encoding.ASCII.GetBytes(firstCertificateAsPem)))
                {
                    await ComposeChain(builder, x509, "http://localhost");
                }
            }
            catch (SignerUriNotFoundException sunfex)
            {
                builder.SetError(CertificateChainStatus.SignerUriNotFound, sunfex);
            }
            catch (SignerDownloadException sdex)
            {
                builder.SetError(CertificateChainStatus.ErrorDownloadingSigner, sdex);
            }
            return(builder.Build());
        }