You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This guide explains how to test ServiceControl with direct HTTPS enabled on Kestrel, without using a reverse proxy. This is useful for testing scenarios like:
3
+
This guide provides scenario-based tests for ServiceControl's direct HTTPS features. Use this to verify Kestrel HTTPS behavior without a reverse proxy.
4
4
5
-
- Direct TLS termination at ServiceControl
6
-
- HTTPS redirection
7
-
- HSTS (HTTP Strict Transport Security)
8
-
- End-to-end encryption testing
5
+
> **Note:** HTTP to HTTPS redirection (`RedirectHttpToHttps`) is designed for reverse proxy scenarios where the proxy forwards HTTP requests to ServiceControl. When running with direct HTTPS, ServiceControl only binds to a single port (HTTPS). To test HTTP to HTTPS redirection, see [Local Reverse Proxy Testing](local-reverseproxy-testing.md).
When prompted for a password, you can use an empty password by pressing Enter, or set a password and note it for the configuration step.
82
+
When prompted for a password, you can use an empty password by pressing Enter, or set a password (e.g., `changeit`) and note it for the configuration step.
83
+
84
+
## Test Scenarios
73
85
74
-
## Step 3: Configure ServiceControl Instances
86
+
All scenarios use environment variables for configuration. Run each scenario from the `src/ServiceControl` directory.
75
87
76
-
Configure HTTPS in the `App.config` file for each ServiceControl instance. See [HTTPS Settings](hosting-guide.md#https-settings) in the Hosting Guide for all available options.
> **Note:**Replace `C:\path\to\repo` with the actual path to your ServiceControl repository. Use the full absolute path to the PFX file.
109
+
> **Note:**The `--ssl-no-revoke` flag is required on Windows because mkcert certificates don't have CRL distribution points, causing `CRYPT_E_NO_REVOCATION_CHECK` errors.
105
110
106
-
## Step 4: Start ServiceControl Instances
111
+
**Expected output:**
107
112
108
-
Start the ServiceControl instances locally using your preferred method:
113
+
```text
114
+
* schannel: SSL/TLS connection renegotiated
115
+
< HTTP/1.1 200 OK
116
+
```
109
117
110
-
### **Option A: Visual Studio**
118
+
The request succeeds over HTTPS. The exact SSL output varies by curl version and platform, but you should see `HTTP/1.1 200 OK` confirming success.
111
119
112
-
1. Open `src/ServiceControl.sln`
113
-
2. Run the desired project(s) with the appropriate launch profile
120
+
### Scenario 2: HTTP Disabled (HTTPS Only)
114
121
115
-
### **Option B: Command Line**
122
+
Verify that HTTP requests fail when only HTTPS is enabled.
116
123
117
-
```bash
118
-
# Run ServiceControl (Primary)
119
-
dotnet run --project src/ServiceControl/ServiceControl.csproj
124
+
**Cleanup and start ServiceControl:**
120
125
121
-
# Run ServiceControl.Audit
122
-
dotnet run --project src/ServiceControl.Audit/ServiceControl.Audit.csproj
126
+
```cmd
127
+
set SERVICECONTROL_HTTPS_ENABLED=true
128
+
set SERVICECONTROL_HTTPS_CERTIFICATEPATH=C:\path\to\ServiceControl\.local\certs\localhost.pfx
129
+
set SERVICECONTROL_HTTPS_CERTIFICATEPASSWORD=changeit
130
+
set SERVICECONTROL_FORWARDEDHEADERS_ENABLED=false
123
131
124
-
# Run ServiceControl.Monitoring
125
-
dotnet run --project src/ServiceControl.Monitoring/ServiceControl.Monitoring.csproj
132
+
dotnet run
126
133
```
127
134
128
-
## Step 5: Verify the Setup
129
-
130
-
Test that HTTPS is working correctly:
135
+
**Test with curl (HTTP):**
131
136
132
-
```bash
133
-
# Test ServiceControl (Primary)
134
-
curl https://localhost:33333/api
137
+
```cmd
138
+
curl http://localhost:33333/api
139
+
```
135
140
136
-
# Test ServiceControl.Audit
137
-
curl https://localhost:44444/api
141
+
**Expected output:**
138
142
139
-
# Test ServiceControl.Monitoring
140
-
curl https://localhost:33633/api
143
+
```text
144
+
curl: (52) Empty reply from server
141
145
```
142
146
143
-
If you've installed mkcert's root CA, the requests should succeed without certificate warnings.
147
+
HTTP requests fail because Kestrel is listening for HTTPS but receives plaintext HTTP, which it cannot process. The server closes the connection without responding.
144
148
145
-
### Testing HTTPS Redirection
149
+
##HTTPS Configuration Reference
146
150
147
-
If `RedirectHttpToHttps` is enabled, HTTP requests should redirect to HTTPS:
|`Https.HstsIncludeSubDomains`|`SERVICECONTROL_HTTPS_HSTSINCLUDESUBDOMAINS`|`false`| Include subdomains in HSTS |
148
160
149
-
```bash
150
-
# This should redirect to https://localhost:33333/api
151
-
curl -v http://localhost:33333/api
152
-
```
161
+
> **Note:** For other instances, replace the `SERVICECONTROL_` prefix with the appropriate instance prefix (see Instance Reference table).
162
+
>
163
+
> **Note:** HSTS is not tested locally because ASP.NET Core excludes localhost from HSTS by default (to prevent accidentally caching HSTS during development). HSTS will work correctly in production with non-localhost hostnames.
153
164
154
-
###Testing HSTS
165
+
## Testing Other Instances
155
166
156
-
If `EnableHsts` is enabled, the response should include the `Strict-Transport-Security` header:
167
+
The same scenarios can be run against ServiceControl.Audit and ServiceControl.Monitoring by:
|`Https.HstsIncludeSubDomains`|`false`| Include subdomains in HSTS |
187
+
**ServiceControl.Monitoring:**
188
+
189
+
```cmd
190
+
set MONITORING_HTTPS_ENABLED=true
191
+
set MONITORING_HTTPS_CERTIFICATEPATH=C:\path\to\ServiceControl\.local\certs\localhost.pfx
192
+
set MONITORING_HTTPS_CERTIFICATEPASSWORD=changeit
193
+
194
+
dotnet run --project src/ServiceControl.Monitoring/ServiceControl.Monitoring.csproj
195
+
```
196
+
197
+
```cmd
198
+
curl --ssl-no-revoke https://localhost:33633/api
199
+
```
173
200
174
201
## Troubleshooting
175
202
@@ -181,16 +208,65 @@ Ensure the `CertificatePath` is an absolute path and the file exists.
181
208
182
209
If you set a password when generating the PFX, ensure it matches `CertificatePassword` in the config.
183
210
184
-
### Certificate errors in browser
211
+
### Certificate errors in browser/curl
185
212
186
213
1. Ensure mkcert's root CA is installed: `mkcert -install`
187
214
2. Restart your browser after installing the root CA
188
215
216
+
### CRYPT_E_NO_REVOCATION_CHECK error in curl
217
+
218
+
Windows curl fails to check certificate revocation for mkcert certificates because they don't have CRL distribution points. Use the `--ssl-no-revoke` flag:
219
+
220
+
```cmd
221
+
curl --ssl-no-revoke https://localhost:33333/api
222
+
```
223
+
189
224
### Port already in use
190
225
191
226
Ensure no other process is using the ServiceControl ports (33333, 44444, 33633).
0 commit comments