public ActionResult DownloadCertBase64(string cert)
        {
            var byteArray = Convert.FromBase64String(cert);
            X509Certificate2 certificate = new X509Certificate2(byteArray);
            var model = new CertificateDetailsApiModel()
            {
                Subject       = certificate.Subject,
                Issuer        = certificate.Issuer,
                Thumbprint    = certificate.Thumbprint,
                SerialNumber  = certificate.SerialNumber,
                NotBefore     = certificate.NotBefore,
                NotAfter      = certificate.NotAfter,
                EncodedBase64 = cert
            };

            return(View(model));
        }
        public async Task <ActionResult> IssuerDetailsAsync(string id, string error)
        {
            AuthorizeClient();
            try
            {
                var issuer = await _opcVault.GetCertificateGroupIssuerCAChainAsync(id);

                var certList = new List <CertificateDetailsApiModel>();
                foreach (var certificate in issuer.Chain)
                {
                    var byteArray         = Convert.FromBase64String(certificate.Certificate);
                    X509Certificate2 cert = new X509Certificate2(byteArray);
                    var model             = new CertificateDetailsApiModel()
                    {
                        Subject      = cert.Subject,
                        Issuer       = cert.Issuer,
                        Thumbprint   = cert.Thumbprint,
                        SerialNumber = cert.SerialNumber,
                        NotBefore    = cert.NotBefore,
                        NotAfter     = cert.NotAfter
                    };
                    certList.Add(model);
                }
                var modelCollection = new CertificateDetailsCollectionApiModel(id)
                {
                    Certificates = certList.ToArray()
                };
                ViewData["ErrorMessage"] = error;
                return(View(modelCollection));
            }
            catch (Exception ex)
            {
                var exError =
                    "Failed to load the Issuer CA Chain " + id + ". " +
                    "Message:" + ex.Message;
                return(RedirectToAction("Index", new { error = exError }));
            }
        }