瀏覽代碼

修改OPCUA服务端 验证机制

Shun 2 年之前
父節點
當前提交
c7b9f5df5e

+ 4 - 0
README.md

@@ -565,3 +565,7 @@ while(true)
 1. OPCUA客户端工具改造完成
 2. OPCUA服务端动态库修改
 3. OPCUA服务端工具改造完成
+
+#### 2023-12-25
+1. 修改OPCUA服务端 验证机制
+

+ 1 - 1
src/YSAI.DAQ.Samples/YSAI.DAQ.Samples.csproj

@@ -98,7 +98,7 @@
   </ItemGroup>
 
   <ItemGroup>
-    <PackageReference Include="YSAI.Mqtt" Version="23.352.38022" />
+    <PackageReference Include="YSAI.Mqtt" Version="23.359.7955" />
     <PackageReference Include="YSAI.Opc" Version="23.356.35571" />
   </ItemGroup>
 

+ 1 - 1
src/YSAI.Mqtt/YSAI.Mqtt.csproj

@@ -3,7 +3,7 @@
     <TargetFrameworks>net6.0;net8.0</TargetFrameworks>
     <ImplicitUsings>enable</ImplicitUsings>
     <Nullable>enable</Nullable>
-    <Version>23.352.38022</Version>
+    <Version>23.359.7955</Version>
     <PackageOutputPath Condition="'$(Configuration)' == 'Release'">../YSAI.Publish/Release</PackageOutputPath>
     <PackageOutputPath Condition="'$(Configuration)' == 'Debug'">../YSAI.Publish/Debug</PackageOutputPath>
     <Authors>Shun</Authors>

+ 3 - 3
src/YSAI.Mqtt/service/MqttServiceOperate.cs

@@ -184,10 +184,10 @@ namespace YSAI.Mqtt.service
         /// <exception cref="NotImplementedException"></exception>
         private Task MqttServer_ValidatingConnectionAsync(ValidatingConnectionEventArgs arg)
         {
-            return Task.Run((Action)(() =>
+            return Task.Run(() =>
             {
                 //验证账号密码是否正确
-                if (!arg.UserName.Equals((string?)basics.UserName) || !arg.Password.Equals(basics.Password))
+                if (arg.UserName != basics.UserName || arg.Password != basics.Password)
                 {
                     arg.ReasonCode = MQTTnet.Protocol.MqttConnectReasonCode.BadUserNameOrPassword;
                     OnEventHandler(this, new EventResult(false, $"[ {Steps.客户端身份验证事件} ]( {arg.ClientId} ) 身份验证异常:{arg.ReasonCode}", arg.ClientId, ResultType.String));
@@ -197,7 +197,7 @@ namespace YSAI.Mqtt.service
                     arg.ReasonCode = MQTTnet.Protocol.MqttConnectReasonCode.Success;
                     OnEventHandler(this, new EventResult(true, $"[ {Steps.客户端身份验证事件} ]( {arg.ClientId} ) 身份验证成功", arg.ClientId, ResultType.String));
                 }
-            }));
+            });
         }
 
         #endregion 私有函数

+ 2 - 2
src/YSAI.Mqtt/service/websocket/MqttWebSocketServiceOperate.cs

@@ -304,7 +304,7 @@ namespace YSAI.Mqtt.service.websocket
             /// <exception cref="NotImplementedException"></exception>
             public Task MqttServer_ValidatingConnectionAsync(ValidatingConnectionEventArgs arg)
             {
-                return Task.Run((Action)(() =>
+                return Task.Run(() =>
                 {
                     //验证账号密码是否正确
                     if (arg.UserName != mqttServiceData_Static.UserName || arg.Password != mqttServiceData_Static.Password)
@@ -317,7 +317,7 @@ namespace YSAI.Mqtt.service.websocket
                         arg.ReasonCode = MQTTnet.Protocol.MqttConnectReasonCode.Success;
                         OnEventHandler_Static?.Invoke(this, new EventResult(true, $"[ {Steps.客户端身份验证事件} ]( {arg.ClientId} ) 身份验证成功", arg.ClientId, ResultType.String));
                     }
-                }));
+                });
             }
         }
     }

+ 1 - 1
src/YSAI.Relay.Samples/YSAI.Relay.Samples.csproj

@@ -8,7 +8,7 @@
   </PropertyGroup>
 
   <ItemGroup>
-    <PackageReference Include="YSAI.Mqtt" Version="23.352.38022" />
+    <PackageReference Include="YSAI.Mqtt" Version="23.359.7955" />
   </ItemGroup>
 
 </Project>

+ 1 - 1
src/YSAI.Tool.Wpf/YSAI.Tool.Wpf.csproj

@@ -24,7 +24,7 @@
 		<PackageReference Include="YSAI.Mewtocol" Version="23.353.7802" />
 		<PackageReference Include="YSAI.Mitsubishi" Version="23.353.7802" />
 		<PackageReference Include="YSAI.Modbus" Version="23.353.7802" />
-		<PackageReference Include="YSAI.Mqtt" Version="23.352.38022" />
+		<PackageReference Include="YSAI.Mqtt" Version="23.359.7955" />
 		<PackageReference Include="YSAI.NetMQ" Version="23.352.38022" />
 		<PackageReference Include="YSAI.Netty" Version="23.352.38022" />
 		<PackageReference Include="YSAI.Omron" Version="23.353.7802" />