public async Task TestRequestAndInstallDnsCertificate()
        {
            var config     = new AppSettingsAuthConfig();
            var client     = ArmHelper.GetWebSiteManagementClient(config);
            var kuduClient = KuduHelper.GetKuduClient(client, config);

            var body = new DnsAzureInstallModel()
            {
                AzureWebAppEnvironment = new AzureWebAppEnvironment(config.Tenant, config.SubscriptionId, config.ClientId, config.ClientSecret, config.ResourceGroupName, config.WebAppName),
                AcmeConfig             = new AcmeConfig()
                {
                    Host              = "letsencrypt.ai4bots.com",
                    PFXPassword       = "******",
                    RegistrationEmail = "*****@*****.**",
                    RSAKeyLength      = 2048
                },
                RelativeRecordSetName = "letsencrypt",
                ZoneName            = "ai4bots.com",
                ResourceGroupName   = "dns",
                SubscriptionId      = new Guid("14fe4c66-c75a-4323-881b-ea53c1d86a9d"),
                CertificateSettings = new CertificateServiceSettings()
            };

            var res = await kuduClient.HttpClient.PostAsync(
                "https://webappcfmv5fy7lcq7o.scm.azurewebsites.net/letsencrypt/api/certificates/challengeprovider/dns/azure/certificateinstall/azurewebapp?api-version=2017-09-01",
                new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, "application/json"));

            await ValidateResponse(body.AcmeConfig, res);
        }
        public KuduFileSystemAuthorizationChallengeProvider(IAzureWebAppEnvironment azureEnvironment, IAuthorizationChallengeProviderConfig config)
        {
            this.config = config;
            var website = ArmHelper.GetWebSiteManagementClient(azureEnvironment);

            this.kuduClient = KuduHelper.GetKuduClient(website, azureEnvironment);
        }
        public async Task TestRequestAndInstallCertificate()
        {
            var config     = new AppSettingsAuthConfig();
            var client     = ArmHelper.GetWebSiteManagementClient(config);
            var kuduClient = KuduHelper.GetKuduClient(client, config);

            var body = new HttpKuduInstallModel()
            {
                AzureEnvironment = new AzureWebAppEnvironment(config.Tenant, config.SubscriptionId, config.ClientId, config.ClientSecret, config.ResourceGroupName, config.WebAppName),
                AcmeConfig       = new AcmeConfig()
                {
                    Host              = "letsencrypt.sjkp.dk",
                    PFXPassword       = "******",
                    RegistrationEmail = "*****@*****.**",
                    RSAKeyLength      = 2048
                },
                AuthorizationChallengeProviderConfig = new AuthorizationChallengeProviderConfig(),
                CertificateSettings = new CertificateServiceSettings()
            };

            var res = await kuduClient.HttpClient.PostAsync(
                "https://webappcfmv5fy7lcq7o.scm.azurewebsites.net/letsencrypt/api/certificates/challengeprovider/http/kudu/certificateinstall/azurewebapp?api-version=2017-09-01",
                new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, "application/json"));

            await ValidateResponse(body.AcmeConfig, res);
        }
コード例 #4
0
        public async Task TestRequestDnsCertificate()
        {
            var config = new AppSettingsAuthConfig();
            var client = await ArmHelper.GetWebSiteManagementClient(config);

            var kuduClient = KuduHelper.GetKuduClient(client, config);

            var body = new DnsAzureModel()
            {
                AzureDnsEnvironment = new AzureDnsEnvironment(config.Tenant, new Guid("14fe4c66-c75a-4323-881b-ea53c1d86a9d"), config.ClientId, config.ClientSecret, "dns", "ai4bots.com", "@"),
                AcmeConfig          = new AcmeConfig()
                {
                    Host              = "ai4bots.com",
                    PFXPassword       = "******",
                    RegistrationEmail = "*****@*****.**",
                    RSAKeyLength      = 2048
                }
            };

            var res = await kuduClient.HttpClient.PostAsync(
                "https://webappcfmv5fy7lcq7o.scm.azurewebsites.net/letsencrypt/api/certificates/challengeprovider/dns/azure?api-version=2017-09-01",
                new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, "application/json"));

            await ValidateResponse(body.AcmeConfig, res);
        }
コード例 #5
0
        public void TestScmUri()
        {
            var model  = new AppSettingsAuthConfig();
            var uri    = "letsencrypt.azurewebsites.net";
            var result = KuduHelper.MakeScmUri(uri, model);

            Assert.AreEqual(new Uri("https://letsencrypt.scm.azurewebsites.net"), result);
        }
コード例 #6
0
        private bool IsBetterRunOnLocalTempStorage()
        {
            bool isKuduAware = KuduHelper.IsKuduAware(
                EnvironmentVariableHelper.GetBuildVariablesFromEnvironmentVariables(_logger),
                _logger);

            bool isBetterRunOnLocalTempStorage = isKuduAware;

            _logger.WriteVerbose("Is Kudu-aware: " + isKuduAware, _Prefix);

            return(isBetterRunOnLocalTempStorage);
        }
コード例 #7
0
        public async Task TestRenewCertificate()
        {
            var config     = new AppSettingsAuthConfig();
            var client     = ArmHelper.GetWebSiteManagementClient(config);
            var kuduClient = KuduHelper.GetKuduClient(client, config);

            var res = await kuduClient.HttpClient.PostAsync("https://webappcfmv5fy7lcq7o-vnext.scm.azurewebsites.net/letsencrypt/api/certificates/renew?api-version=2017-09-01", new StringContent(""));

            Assert.AreEqual(System.Net.HttpStatusCode.OK, res.StatusCode);

            var model = JsonConvert.DeserializeObject <CertificateInstallModel[]>(await res.Content.ReadAsStringAsync());

            Assert.AreEqual(1, model.Count());

            File.WriteAllBytes(Path.GetFileName(model.First().CertificateInfo.Name), model.First().CertificateInfo.PfxCertificate);
        }
コード例 #8
0
        public async Task GetPublishingCredentials()
        {
            var model  = new AppSettingsAuthConfig();
            var helper = ArmHelper.GetWebSiteManagementClient(model);

            var kuduClient = KuduHelper.GetKuduClient(helper, model);

            //var res = await kuduClient.GetScmInfo();

            var dir = await kuduClient.GetFile("site/wwwroot/host.json");

            using (var ms = new MemoryStream())
            {
                var sw = new StreamWriter(ms);
                sw.WriteLine("Hell asd asd asd ");
                sw.Flush();

                await kuduClient.PutFile("site/wwwroot/.well-known/acme-challenge2/test.json", ms);
            }
        }
        private async Task <KuduRestClient> GetKuduRestClient()
        {
            var website = await ArmHelper.GetWebSiteManagementClient(azureEnvironment);

            return(KuduHelper.GetKuduClient(website, azureEnvironment));
        }