Skip to content

Commit

Permalink
Added docs for server configuration (#147)
Browse files Browse the repository at this point in the history
* Added docs for server configuration

* Added option to bypass SSL certificate for SignalR in AxoDialogLocator.

* Docs update to match the latest change.

* Created DeveloperSettings static class and changed BypassSSLCertificate attribute in DialogClient.cs
  • Loading branch information
Brano5 authored Jul 31, 2023
1 parent c475844 commit e008e40
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 5 deletions.
52 changes: 52 additions & 0 deletions docfx/articles/configuration/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# How to configure Blazor server for Siemens panel

To configure Blazor Server, you need to follow these two steps:

## 1. Change the default IP Address

To modify the IP address of the website, you have two options:

1. In Program.cs
Inside the Program.cs file, add the following lines to specify the URLs:

~~~ C#
builder.WebHost.UseUrls("http://10.10.10.198:5262;https://10.10.10.198:7292");
~~~

or

~~~ C#
builder.WebHost.UseUrls("http://*:5262;https://*:7292");
~~~

2. In launchSettings.json
Open the launchSettings.json file and modify the 'applicationUrl' under the profiles section. For example:

~~~ JSON
"applicationUrl": "http://10.10.10.198:5262;https://10.10.10.198:7292"
~~~

Please note that the IP address corresponds to the IP address of your network adapter.

## 2. Add rules to the firewall

Follow these steps to add rules for the desired ports in the Windows Defender Firewall:

1. Go to Control Panel > Windows Defender Firewall > Advanced Settings

2. In the Inbound Rules section, add the rules for the ports you wish to use.

If you are using Eset, you should perform the following steps:

1. Navigate to Eset > Setup > Network > Click on settings next to Firewall > Configure.

2. Check the option `Also evaluate rules from Windows Firewall`` or add the rule directly in Eset.
If you using Eset you need to: Eset > Setup > Network > click on settings next to Firewall > Configure

### Warning

If you intend to use HTTPS with a self-signed SSL certificate, make sure to adjust the `DeveloperSettings.BypassSSLCertificate` attribute in `Program.cs` to `true`, before start your application. Here's an example of how to do it:

~~~ C#
DeveloperSettings.BypassSSLCertificate = false;
~~~
3 changes: 2 additions & 1 deletion docfx/articles/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,5 @@
href: ~/articles/themes/README.md
- name: Template localization
href: ~/articles/localization/README.md

- name: Server configuration
href: ~/articles/configuration/README.md
32 changes: 28 additions & 4 deletions src/core/src/AXOpen.Core.Blazor/AxoDialogs/Hubs/DialogClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,34 @@ public async Task StartAsync()
{
if (!_isConnected)
{
_hubConnection = new HubConnectionBuilder()
.WithUrl(_hubUrl)
.Build();

if (DeveloperSettings.BypassSSLCertificate)
{
_hubConnection = new HubConnectionBuilder()
.WithUrl(_hubUrl, options =>
{
options.UseDefaultCredentials = true;
options.HttpMessageHandlerFactory = (msg) =>
{
if (msg is HttpClientHandler clientHandler)
{
// bypass SSL certificate
clientHandler.ServerCertificateCustomValidationCallback +=
(sender, certificate, chain, sslPolicyErrors) => { return true; };
}
return msg;
};
})
.Build();
}
else
{
_hubConnection = new HubConnectionBuilder()
.WithUrl(_hubUrl)
.Build();
}

_hubConnection.On<string>(DialogMessages.RECEIVE_DIALOG_OPEN, (message) =>
{
HandleReceiveMessage(message);
Expand Down
17 changes: 17 additions & 0 deletions src/core/src/AXOpen.Core.Blazor/DeveloperSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AXOpen.Core.Blazor
{
public static class DeveloperSettings
{
/// <summary>
/// Using SSL certificate for SignalR connection (default value is false).
/// </summary>
///
public static bool BypassSSLCertificate { get; set; } = false;
}
}

0 comments on commit e008e40

Please sign in to comment.