-
Notifications
You must be signed in to change notification settings - Fork 39
Fix "The remote certificate is invalid according to the validation procedure" bug. #305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
a7f714e
4d20e38
068abbb
7d2f783
3866e59
2e1ecf4
d6d8d80
47ee0de
3e69ec8
ec3104b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,6 +35,12 @@ public void ConfigureServices(IServiceCollection services) | |
| c.ReturnHttpNotAcceptable = true; | ||
| }); | ||
|
|
||
| services.AddHttpsRedirection(options => | ||
| { | ||
| options.RedirectStatusCode = StatusCodes.Status307TemporaryRedirect; | ||
| options.HttpsPort = Configuration.GetValue<int?>("SETTINGS:HTTPSPORT", 443); | ||
| }); | ||
|
|
||
| services.AddSingleton<IBridgeStateService, BridgeStateService>(); | ||
| services.AddSingleton<IBridgeOperationService, BrigeOperationService>(); | ||
| services.AddSingleton<ISettingsService, SettingsService>(); | ||
|
|
@@ -65,11 +71,15 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) | |
| app.UseExceptionHandler("/Home/Error"); | ||
| } | ||
|
|
||
| if (Configuration.GetValue("SETTINGS:HTTPSREDIRECT", false)) | ||
| { | ||
| app.UseHttpsRedirection(); | ||
| } | ||
|
Comment on lines
+74
to
+77
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please document this change... What this feature is doing? How to use it?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. HTTPS redirection can be enforced by setting the environment variable Z2MA_SETTINGS__HTTPSREDIRECT to true. If the variable is not set the value defaults to false. When set to true then all HTTP requests are redirected to HTTPS. Setting the HTTPS port is essential when running Zigbee2MqttAssistant from docker and the outgoing port is not set 443. Here is an example of a docker-compose with accompanying .env file which uses HTTPS and HTTPS redirection (assuming the PR will be merged). docker-compose.yml file: .env file: To generate a self-signed certificate replace 'XX' and webserver addresses and IPs in the following commands: The entry 'cert_password' in the .env file has to be replaced by the password you just entered when creating the PFX cert file. |
||
|
|
||
| app.UseStaticFiles(); | ||
|
|
||
| app.UseRouting(); | ||
|
|
||
|
|
||
| app.UseEndpoints(endpoints => | ||
| { | ||
| endpoints.MapControllerRoute( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch 👍