diff --git a/LetsEncrypt-SiteExtension.sln b/LetsEncrypt-SiteExtension.sln index e5deb4e..54b897d 100644 --- a/LetsEncrypt-SiteExtension.sln +++ b/LetsEncrypt-SiteExtension.sln @@ -30,10 +30,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ACMESharp", "ACMESharp", "{E4B09348-2E98-4A58-8D5A-B55231D6A2E3}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ACMESharp", "ACMESharp\ACMESharp\ACMESharp\ACMESharp.csproj", "{D551234B-0A8D-4DEE-8178-A81998DF0EDB}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ACMESharp.PKI.Providers.BouncyCastle", "ACMESharp\ACMESharp\ACMESharp.PKI.Providers.BouncyCastle\ACMESharp.PKI.Providers.BouncyCastle.csproj", "{473BFF7D-C7F0-471D-B7A3-19AD9ADFDBA9}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -104,38 +100,10 @@ Global {284F0226-F481-4C10-A408-4146FDBB71CC}.Release|x64.Build.0 = Release|x64 {284F0226-F481-4C10-A408-4146FDBB71CC}.Release|x86.ActiveCfg = Release|x86 {284F0226-F481-4C10-A408-4146FDBB71CC}.Release|x86.Build.0 = Release|x86 - {D551234B-0A8D-4DEE-8178-A81998DF0EDB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D551234B-0A8D-4DEE-8178-A81998DF0EDB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D551234B-0A8D-4DEE-8178-A81998DF0EDB}.Debug|x64.ActiveCfg = Debug|Any CPU - {D551234B-0A8D-4DEE-8178-A81998DF0EDB}.Debug|x64.Build.0 = Debug|Any CPU - {D551234B-0A8D-4DEE-8178-A81998DF0EDB}.Debug|x86.ActiveCfg = Debug|Any CPU - {D551234B-0A8D-4DEE-8178-A81998DF0EDB}.Debug|x86.Build.0 = Debug|Any CPU - {D551234B-0A8D-4DEE-8178-A81998DF0EDB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D551234B-0A8D-4DEE-8178-A81998DF0EDB}.Release|Any CPU.Build.0 = Release|Any CPU - {D551234B-0A8D-4DEE-8178-A81998DF0EDB}.Release|x64.ActiveCfg = Release|Any CPU - {D551234B-0A8D-4DEE-8178-A81998DF0EDB}.Release|x64.Build.0 = Release|Any CPU - {D551234B-0A8D-4DEE-8178-A81998DF0EDB}.Release|x86.ActiveCfg = Release|Any CPU - {D551234B-0A8D-4DEE-8178-A81998DF0EDB}.Release|x86.Build.0 = Release|Any CPU - {473BFF7D-C7F0-471D-B7A3-19AD9ADFDBA9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {473BFF7D-C7F0-471D-B7A3-19AD9ADFDBA9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {473BFF7D-C7F0-471D-B7A3-19AD9ADFDBA9}.Debug|x64.ActiveCfg = Debug|Any CPU - {473BFF7D-C7F0-471D-B7A3-19AD9ADFDBA9}.Debug|x64.Build.0 = Debug|Any CPU - {473BFF7D-C7F0-471D-B7A3-19AD9ADFDBA9}.Debug|x86.ActiveCfg = Debug|Any CPU - {473BFF7D-C7F0-471D-B7A3-19AD9ADFDBA9}.Debug|x86.Build.0 = Debug|Any CPU - {473BFF7D-C7F0-471D-B7A3-19AD9ADFDBA9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {473BFF7D-C7F0-471D-B7A3-19AD9ADFDBA9}.Release|Any CPU.Build.0 = Release|Any CPU - {473BFF7D-C7F0-471D-B7A3-19AD9ADFDBA9}.Release|x64.ActiveCfg = Release|Any CPU - {473BFF7D-C7F0-471D-B7A3-19AD9ADFDBA9}.Release|x64.Build.0 = Release|Any CPU - {473BFF7D-C7F0-471D-B7A3-19AD9ADFDBA9}.Release|x86.ActiveCfg = Release|Any CPU - {473BFF7D-C7F0-471D-B7A3-19AD9ADFDBA9}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {D551234B-0A8D-4DEE-8178-A81998DF0EDB} = {E4B09348-2E98-4A58-8D5A-B55231D6A2E3} - {473BFF7D-C7F0-471D-B7A3-19AD9ADFDBA9} = {E4B09348-2E98-4A58-8D5A-B55231D6A2E3} - EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {CE278D6B-F8FA-4F40-A67B-A8367F40FCA4} EndGlobalSection diff --git a/LetsEncrypt-SiteExtension/Controllers/Api/CertificateController.cs b/LetsEncrypt-SiteExtension/Controllers/Api/CertificateController.cs index 0da8d02..1eb05d7 100644 --- a/LetsEncrypt-SiteExtension/Controllers/Api/CertificateController.cs +++ b/LetsEncrypt-SiteExtension/Controllers/Api/CertificateController.cs @@ -83,69 +83,5 @@ public async Task GenerateAndInstallBlob(HttpKuduInstallModel return Ok(await mgr.AddCertificate()); } - - /// - /// Requests a Let's Encrypt certificate using the DNS challenge, using Azure DNS. - /// - /// - /// - /// - [HttpPost] - [Route("api/certificates/challengeprovider/dns/azure")] - [ResponseType(typeof(CertificateInstallModel))] - public async Task Generate(DnsAzureModel model, [FromUri(Name = "api-version")]string apiversion = null) - { - if (!ModelState.IsValid) - { - return BadRequest(ModelState); - } - - var res = await CertificateManager.RequestDnsChallengeCertificate(model.AzureDnsEnvironment, model.AcmeConfig); - - return Ok(res); - } - - /// - /// Requests a Let's Encrypt certificate using the DNS challenge, using Azure DNS. - /// - /// - /// - /// - [HttpPost] - [Route("api/certificates/challengeprovider/dns-v2/azure")] - [ResponseType(typeof(CertificateInstallModel))] - public async Task Generate_v2(DnsAzureModel model, [FromUri(Name = "api-version")]string apiversion = null) - { - if (!ModelState.IsValid) - { - return BadRequest(ModelState); - } - - var res = await CertificateManager.RequestDnsChallengeCertificate(model.AzureDnsEnvironment, model.AcmeConfig); - - return Ok(res); - } - - /// - /// Requests a Let's Encrypt certificate using the DNS challenge, using Azure DNS. The - /// certificate is installed to the web app. - /// - /// - /// - /// - [HttpPost] - [Route("api/certificates/challengeprovider/dns/azure/certificateinstall/azurewebapp")] - [ResponseType(typeof(CertificateInstallModel))] - public async Task GenerateAndInstall(DnsAzureInstallModel model, [FromUri(Name = "api-version")]string apiversion = null) - { - if (!ModelState.IsValid) - { - return BadRequest(ModelState); - } - - var mgr = CertificateManager.CreateAzureDnsWebAppCertificateManager(model.AzureWebAppEnvironment, model.AcmeConfig, model.CertificateSettings, model); - - return Ok(await mgr.AddCertificate()); - } } } \ No newline at end of file diff --git a/LetsEncrypt-SiteExtension/Controllers/HomeController.cs b/LetsEncrypt-SiteExtension/Controllers/HomeController.cs index 38be016..70097e8 100644 --- a/LetsEncrypt-SiteExtension/Controllers/HomeController.cs +++ b/LetsEncrypt-SiteExtension/Controllers/HomeController.cs @@ -230,11 +230,10 @@ public async Task Install(RequestAndInstallModel model) Name = "email", Value = model.Email }); - var baseUri = model.UseStaging == false ? "https://acme-v01.api.letsencrypt.org/" : "https://acme-staging.api.letsencrypt.org/"; s.Add(new SettingEntry() { - Name = "baseUri", - Value = baseUri + Name = "useStaging", + Value = model.UseStaging.ToString() }); SettingsStore.Instance.Save(s); var settings = new AppSettingsAuthConfig(); @@ -242,7 +241,7 @@ public async Task Install(RequestAndInstallModel model) { RegistrationEmail = model.Email, Host = model.Hostnames.First(), - BaseUri = baseUri, + UseProduction = !model.UseStaging, AlternateNames = model.Hostnames.Skip(1).ToList(), PFXPassword = settings.PFXPassword, RSAKeyLength = settings.RSAKeyLength, diff --git a/LetsEncrypt-SiteExtension/Web.config b/LetsEncrypt-SiteExtension/Web.config index 05f10f5..a44357d 100644 --- a/LetsEncrypt-SiteExtension/Web.config +++ b/LetsEncrypt-SiteExtension/Web.config @@ -133,6 +133,14 @@ + + + + + + + + diff --git a/LetsEncrypt.SiteExtension.Core/CertificateManager.cs b/LetsEncrypt.SiteExtension.Core/CertificateManager.cs index cee4c53..b236924 100644 --- a/LetsEncrypt.SiteExtension.Core/CertificateManager.cs +++ b/LetsEncrypt.SiteExtension.Core/CertificateManager.cs @@ -93,32 +93,6 @@ public static CertificateManager CreateKuduWebAppCertificateManager(IAzureWebApp return new CertificateManager(settings, acmeConfig, new WebAppCertificateService(settings, certSettings), new KuduFileSystemAuthorizationChallengeProvider(settings, authProviderConfig)); } - /// - /// Returns a configured to use DNS Challenge, placing the challenge record in Azure DNS, - /// and assigning the obtained certificate directly to the web app service. - /// - /// - /// - /// - /// - /// - public static CertificateManager CreateAzureDnsWebAppCertificateManager(IAzureWebAppEnvironment settings, IAcmeConfig acmeConfig, IWebAppCertificateSettings certSettings, IAzureDnsEnvironment dnsEnvironment) - { - return new CertificateManager(settings, acmeConfig, new WebAppCertificateService(settings, certSettings), new AzureDnsAuthorizationChallengeProvider(dnsEnvironment)); - } - - /// - /// Request a certificate from lets encrypt using the DNS challenge, placing the challenge record in Azure DNS. - /// The certifiacte is not assigned, but just returned. - /// - /// - /// - /// - public static async Task RequestDnsChallengeCertificate(IAzureDnsEnvironment azureDnsEnvironment, IAcmeConfig acmeConfig) - { - return await new CertificateManager(null, acmeConfig, null, new AzureDnsAuthorizationChallengeProvider(azureDnsEnvironment)).RequestInternalAsync(acmeConfig); - } - /// /// Used for automatic installation of letsencrypt certificate @@ -186,7 +160,8 @@ public async Task> RenewCertificate(bool skipInsta RegistrationEmail = this.acmeConfig.RegistrationEmail ?? ss.FirstOrDefault(s => s.Name == "email").Value, Host = sslStates.First().Name, - BaseUri = this.acmeConfig.BaseUri ?? ss.FirstOrDefault(s => s.Name == "baseUri").Value, + BaseUri = this.acmeConfig.BaseUri, + UseProduction = !bool.Parse(ss.FirstOrDefault(s => s.Name == "useStaging")?.Value ?? false.ToString()), AlternateNames = sslStates.Skip(1).Select(s => s.Name).ToList(), PFXPassword = this.acmeConfig.PFXPassword, RSAKeyLength = this.acmeConfig.RSAKeyLength diff --git a/LetsEncrypt.SiteExtension.Core/LetsEncrypt.Azure.Core.csproj b/LetsEncrypt.SiteExtension.Core/LetsEncrypt.Azure.Core.csproj index 464f7cd..974afe7 100644 --- a/LetsEncrypt.SiteExtension.Core/LetsEncrypt.Azure.Core.csproj +++ b/LetsEncrypt.SiteExtension.Core/LetsEncrypt.Azure.Core.csproj @@ -69,6 +69,12 @@ MinimumRecommendedRules.ruleset + + ..\packages\Portable.BouncyCastle.1.8.5\lib\net40\BouncyCastle.Crypto.dll + + + ..\packages\Certes.2.3.3\lib\net45\Certes.dll + ..\packages\Microsoft.Azure.KeyVault.Core.3.0.1\lib\net452\Microsoft.Azure.KeyVault.Core.dll @@ -164,6 +170,9 @@ ..\packages\System.Security.Cryptography.X509Certificates.4.3.2\lib\net46\System.Security.Cryptography.X509Certificates.dll + + ..\packages\System.ValueTuple.4.4.0\lib\netstandard1.0\System.ValueTuple.dll + @@ -192,11 +201,9 @@ - + - - @@ -222,16 +229,6 @@ Designer - - - {473bff7d-c7f0-471d-b7a3-19ad9adfdba9} - ACMESharp.PKI.Providers.BouncyCastle - - - {d551234b-0a8d-4dee-8178-a81998df0edb} - ACMESharp - -