Example #1
0
        public async Task <byte[]> GetCertificate()
        {
            Email = await dbConfiguration.Get <WebConfiguration>(x => x.EmailAddress);

            Hostname = await dbConfiguration.Get <WebConfiguration>(x => x.Hostname);

            if (!string.IsNullOrEmpty(Email) && !string.IsNullOrEmpty(Hostname))
            {
                byte[] certificate = await RequestNewCertificate();

                return(certificate);
            }

            logger.LogDebug("LetsEncrypt: email or hostname not configured.");

            return(null);
        }
        private async Task <X509Certificate2> GetExistingCertificate()
        {
            string pfx = await dbConfiguration.Get <WebConfiguration>(x => x.Certificate);

            return(!string.IsNullOrEmpty(pfx) ? new X509Certificate2(Convert.FromBase64String(pfx)) : null);
        }