Beispiel #1
0
        private async Task HttpsHelloWorldCerts(TestVariant variant, bool sendClientCert)
        {
            var port = TestPortHelper.GetNextSSLPort();
            var deploymentParameters = new IISDeploymentParameters(variant)
            {
                ApplicationPath        = Helpers.GetOutOfProcessTestSitesPath(),
                ApplicationBaseUriHint = $"https://localhost:{port}/",
            };

            deploymentParameters.AddHttpsToServerConfig();

            var deploymentResult = await DeployAsync(deploymentParameters);

            var handler = new HttpClientHandler
            {
                ServerCertificateCustomValidationCallback = (a, b, c, d) => true,
                ClientCertificateOptions = ClientCertificateOption.Manual
            };

            if (sendClientCert)
            {
                X509Certificate2 clientCert = FindClientCert();
                Assert.NotNull(clientCert);
                handler.ClientCertificates.Add(clientCert);
            }

            var client = deploymentResult.CreateRetryClient(handler);

            // Request to base address and check if various parts of the body are rendered & measure the cold startup time.
            var response = await client.GetAsync("checkclientcert");

            var responseText = await response.Content.ReadAsStringAsync();

            if (sendClientCert)
            {
                Assert.Equal("Scheme:https; Original:http; has cert? True", responseText);
            }
            else
            {
                Assert.Equal("Scheme:https; Original:http; has cert? False", responseText);
            }
        }
Beispiel #2
0
        public async Task HttpsHelloWorld(TestVariant variant)
        {
            var port = TestPortHelper.GetNextSSLPort();
            var deploymentParameters = new IISDeploymentParameters(variant)
            {
                ApplicationPath        = Helpers.GetOutOfProcessTestSitesPath(),
                ApplicationBaseUriHint = $"https://localhost:{port}/"
            };

            deploymentParameters.AddHttpsToServerConfig();

            var deploymentResult = await DeployAsync(deploymentParameters);

            var handler = new HttpClientHandler
            {
                ServerCertificateCustomValidationCallback = (a, b, c, d) => true
            };
            var client   = deploymentResult.CreateRetryClient(handler);
            var response = await client.GetAsync("HttpsHelloWorld");

            var responseText = await response.Content.ReadAsStringAsync();

            Assert.Equal("Scheme:https; Original:http", responseText);
        }