提交 f343eeef 编写于 作者: 麦壳饼's avatar 麦壳饼

调整证书加载和实用。 现在生成的证书可以通过mqtt.fx 链接了。

上级 50a5e649
......@@ -8,17 +8,15 @@ namespace IoTSharp.Contracts
public int Port { get; set; } = 1883;
public int TlsPort { get; set; } = 8883;
public bool EnableTls { get; set; } = false;
public string Certificate { get; set; }
public SslProtocols SslProtocol { get; set; } = SslProtocols.None;
public SslProtocols SslProtocol { get; set; } = SslProtocols.Tls12;
public bool PersistRetainedMessages { get; set; }
X509Certificate2 _CACertificate;
public X509Certificate2 CACertificate
{
get
{
if (_CACertificate == null)
if (_CACertificate == null && EnableTls)
{
if (System.IO.File.Exists(CACertificateFile) && System.IO.File.Exists(CAPrivateKeyFile))
{
......@@ -36,7 +34,7 @@ namespace IoTSharp.Contracts
{
get
{
if (_BrokerCertificate == null)
if (_BrokerCertificate == null && EnableTls)
{
if (System.IO.File.Exists(CertificateFile) && System.IO.File.Exists(PrivateKeyFile))
{
......
......@@ -97,6 +97,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IoTSharp.EventBus.Shashlik"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IoTSharp.Extensions.DependencyInjection", "IoTSharp.Extensions.DependencyInjection\IoTSharp.Extensions.DependencyInjection.csproj", "{A8C6D097-3EAD-475A-9E65-F0904C44425B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IoTSharp.Extensions.X509", "IoTSharp.Extensions.X509\IoTSharp.Extensions.X509.csproj", "{369A04BA-4CF0-4122-AD66-9D27AD52B3E0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug_VUE|Any CPU = Debug_VUE|Any CPU
......@@ -322,6 +324,14 @@ Global
{A8C6D097-3EAD-475A-9E65-F0904C44425B}.Release_VUE|Any CPU.Build.0 = Release|Any CPU
{A8C6D097-3EAD-475A-9E65-F0904C44425B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A8C6D097-3EAD-475A-9E65-F0904C44425B}.Release|Any CPU.Build.0 = Release|Any CPU
{369A04BA-4CF0-4122-AD66-9D27AD52B3E0}.Debug_VUE|Any CPU.ActiveCfg = Debug|Any CPU
{369A04BA-4CF0-4122-AD66-9D27AD52B3E0}.Debug_VUE|Any CPU.Build.0 = Debug|Any CPU
{369A04BA-4CF0-4122-AD66-9D27AD52B3E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{369A04BA-4CF0-4122-AD66-9D27AD52B3E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{369A04BA-4CF0-4122-AD66-9D27AD52B3E0}.Release_VUE|Any CPU.ActiveCfg = Release|Any CPU
{369A04BA-4CF0-4122-AD66-9D27AD52B3E0}.Release_VUE|Any CPU.Build.0 = Release|Any CPU
{369A04BA-4CF0-4122-AD66-9D27AD52B3E0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{369A04BA-4CF0-4122-AD66-9D27AD52B3E0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
......@@ -11,7 +11,6 @@ using IoTSharp.FlowRuleEngine;
using IoTSharp.Gateways;
using IoTSharp.Models;
using IoTSharp.Storage;
using IoTSharp.X509Extensions;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Identity;
......@@ -44,6 +43,7 @@ using Shashlik.EventBus.Utils;
using static CoAP.Net.Exchange;
using System.Runtime.Intrinsics.X86;
using CoAP;
using IoTSharp.Extensions.X509;
namespace IoTSharp.Controllers
{
......
using IoTSharp.Contracts;
using IoTSharp.Data;
using IoTSharp.Dtos;
using IoTSharp.X509Extensions;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Identity;
......
......@@ -5,7 +5,6 @@ using IoTSharp.Data;
using IoTSharp.Data.Extensions;
using IoTSharp.Extensions;
using IoTSharp.Services;
using IoTSharp.X509Extensions;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Identity;
......@@ -32,6 +31,7 @@ using System.Security.Claims;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Text.RegularExpressions;
using IoTSharp.Extensions.X509;
namespace IoTSharp
{
......
......@@ -63,7 +63,6 @@ namespace IoTSharp
public static void UseIotSharpMqttServer(this IApplicationBuilder app)
{
var mqttEvents = app.ApplicationServices.CreateScope().ServiceProvider.GetService<MQTTService>();
app.UseMqttServer(server =>
{
server.WithAttributeRouting(app.ApplicationServices, true);
......
......@@ -69,7 +69,6 @@
<PackageReference Include="Figgle" Version="0.4.0" />
<PackageReference Include="hyjiacan.pinyin4net" Version="4.1.1" />
<PackageReference Include="IoTSharp.CoAP.NET" Version="2.0.8" />
<PackageReference Include="IoTSharp.X509Extensions" Version="2.0.36" />
<PackageReference Include="Jdenticon-net" Version="3.1.2" />
<PackageReference Include="Jdenticon.AspNetCore" Version="3.1.2" />
<PackageReference Include="LiteDB" Version="5.0.12" />
......
......@@ -11,6 +11,10 @@
"IoTSharp": "Server=localhost;Database=IoTSharp20222;Username=postgres;Password=future;",
"TelemetryStorage": "Server=localhost;Database=IoTSharp20222;Username=postgres;Password=future;"
},
"MqttBroker": {
"EnableTls": true,
"SslProtocol": 12288
},
"JwtKey": "iotsharpiotsharpiotsharpiotsharpiotsharp",
"JwtExpireHours": 3,
"JwtIssuer": "IoTSharp.Net",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册