Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET Platform
MQTTnet
提交
0bb4c6ef
MQTTnet
项目概览
dotNET Platform
/
MQTTnet
10 个月 前同步成功
通知
0
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
MQTTnet
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
0bb4c6ef
编写于
5月 13, 2023
作者:
C
Christian
提交者:
GitHub
5月 13, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Expose more TLS options (#1737)
上级
449624fd
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
49 addition
and
60 deletion
+49
-60
.github/workflows/ReleaseNotes.md
.github/workflows/ReleaseNotes.md
+5
-1
Source/MQTTnet.Extensions.ManagedClient/MQTTnet.Extensions.ManagedClient.csproj
...ons.ManagedClient/MQTTnet.Extensions.ManagedClient.csproj
+1
-1
Source/MQTTnet.Extensions.Rpc/MQTTnet.Extensions.Rpc.csproj
Source/MQTTnet.Extensions.Rpc/MQTTnet.Extensions.Rpc.csproj
+1
-1
Source/MQTTnet.Extensions.WebSocket4Net/MQTTnet.Extensions.WebSocket4Net.csproj
...ons.WebSocket4Net/MQTTnet.Extensions.WebSocket4Net.csproj
+1
-1
Source/MQTTnet.Tests/Formatter/MqttPacketSerialization_V3_Tests.cs
...TTnet.Tests/Formatter/MqttPacketSerialization_V3_Tests.cs
+1
-1
Source/MQTTnet/Client/Options/MqttClientTlsOptions.cs
Source/MQTTnet/Client/Options/MqttClientTlsOptions.cs
+14
-3
Source/MQTTnet/Diagnostics/Runtime/TargetFrameworkProvider.cs
...ce/MQTTnet/Diagnostics/Runtime/TargetFrameworkProvider.cs
+2
-0
Source/MQTTnet/Formatter/MqttConnectReasonCodeConverter.cs
Source/MQTTnet/Formatter/MqttConnectReasonCodeConverter.cs
+4
-45
Source/MQTTnet/Formatter/V5/MqttV5PacketDecoder.cs
Source/MQTTnet/Formatter/V5/MqttV5PacketDecoder.cs
+3
-0
Source/MQTTnet/Implementations/MqttTcpChannel.cs
Source/MQTTnet/Implementations/MqttTcpChannel.cs
+13
-5
Source/MQTTnet/Implementations/MqttWebSocketChannel.cs
Source/MQTTnet/Implementations/MqttWebSocketChannel.cs
+2
-0
Source/MQTTnet/MQTTnet.csproj
Source/MQTTnet/MQTTnet.csproj
+1
-1
Source/MQTTnet/Packets/MqttDisconnectPacket.cs
Source/MQTTnet/Packets/MqttDisconnectPacket.cs
+1
-1
未找到文件。
.github/workflows/ReleaseNotes.md
浏览文件 @
0bb4c6ef
*
[Core] Add validation of maximum string lengths (#1718).
*
[Core] Added .NET 4.8 builds (#1729).
*
[Core] Exposed more details of DISCONNECT packet in log (#1729).
*
[Client] Added overloads for setting packet payload and will payload (#1720).
*
[Client] The proper connect result is now exposed in the _Disconnected_ event when authentication fails (#1139).
*
[Client] The proper connect result is now exposed in the _Disconnected_ event when authentication fails (#1139).
*
[Client] Exposed more TLS options (#1729).
*
[Client] Fixed wrong return code conversion (#1729).
*
[Server] Improved performance by changing internal locking strategy for subscriptions (#1716, thanks to @zeheng).
Source/MQTTnet.Extensions.ManagedClient/MQTTnet.Extensions.ManagedClient.csproj
浏览文件 @
0bb4c6ef
...
...
@@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFrameworks>netstandard1.3;netstandard2.0;netstandard2.1;netcoreapp3.1;net5.0;net6.0;net7.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net452;net461</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net452;net461
;net48
</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' AND '$(MSBuildRuntimeType)' != 'Core' ">$(TargetFrameworks);uap10.0</TargetFrameworks>
<AssemblyName>MQTTnet.Extensions.ManagedClient</AssemblyName>
...
...
Source/MQTTnet.Extensions.Rpc/MQTTnet.Extensions.Rpc.csproj
浏览文件 @
0bb4c6ef
...
...
@@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFrameworks>netstandard1.3;netstandard2.0;netstandard2.1;netcoreapp3.1;net5.0;net6.0;net7.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net452;net461</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net452;net461
;net48
</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' AND '$(MSBuildRuntimeType)' != 'Core' ">$(TargetFrameworks);uap10.0</TargetFrameworks>
<AssemblyName>MQTTnet.Extensions.Rpc</AssemblyName>
...
...
Source/MQTTnet.Extensions.WebSocket4Net/MQTTnet.Extensions.WebSocket4Net.csproj
浏览文件 @
0bb4c6ef
...
...
@@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFrameworks>netstandard1.3;netstandard2.0;netstandard2.1;netcoreapp3.1;net5.0;net6.0;net7.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net452;net461</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net452;net461
;net48
</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' AND '$(MSBuildRuntimeType)' != 'Core' ">$(TargetFrameworks);uap10.0</TargetFrameworks>
<AssemblyName>MQTTnet.Extensions.WebSocket4Net</AssemblyName>
...
...
Source/MQTTnet.Tests/Formatter/MqttPacketSerialization_V3_Tests.cs
浏览文件 @
0bb4c6ef
...
...
@@ -78,7 +78,7 @@ namespace MQTTnet.Tests.Formatter
Assert
.
IsNull
(
deserialized
.
UserProperties
);
// Not supported in v3.1.1
}
[
TestMethod
]
[
TestMethod
]
public
void
Serialize_Full_MqttConnAckPacket_V310
()
{
var
connAckPacket
=
new
MqttConnAckPacket
...
...
Source/MQTTnet/Client/Options/MqttClientTlsOptions.cs
浏览文件 @
0bb4c6ef
...
...
@@ -4,6 +4,7 @@
using
System
;
using
System.Collections.Generic
;
using
System.Net.Security
;
using
System.Security.Authentication
;
using
System.Security.Cryptography.X509Certificates
;
...
...
@@ -30,11 +31,21 @@ namespace MQTTnet.Client
#endif
#if NETCOREAPP3_1_OR_GREATER
public
List
<
System
.
Net
.
Security
.
SslApplicationProtocol
>
ApplicationProtocols
{
get
;
set
;
}
public
System
.
Net
.
Security
.
CipherSuitesPolicy
CipherSuitesPolicy
{
get
;
set
;
}
public
List
<
SslApplicationProtocol
>
ApplicationProtocols
{
get
;
set
;
}
public
CipherSuitesPolicy
CipherSuitesPolicy
{
get
;
set
;
}
public
EncryptionPolicy
EncryptionPolicy
{
get
;
set
;
}
=
EncryptionPolicy
.
RequireEncryption
;
public
bool
AllowRenegotiation
{
get
;
set
;
}
=
true
;
#endif
/// <summary>
/// Gets or sets the target host.
/// If the value is null or empty the same host as the TCP socket host will be used.
/// </summary>
public
string
TargetHost
{
get
;
set
;
}
#if NET48 || NETCOREAPP3_1_OR_GREATER
public
SslProtocols
SslProtocol
{
get
;
set
;
}
=
SslProtocols
.
Tls12
|
SslProtocols
.
Tls13
;
#else
...
...
Source/MQTTnet/Diagnostics/Runtime/TargetFrameworkProvider.cs
浏览文件 @
0bb4c6ef
...
...
@@ -16,6 +16,8 @@ namespace MQTTnet.Diagnostics
return
"net461"
;
#elif NET472
return
"net472"
;
#elif NET48
return
"net48"
;
#elif NETSTANDARD1_3
return
"netstandard1.3"
;
#elif NETSTANDARD2_0
...
...
Source/MQTTnet/Formatter/MqttConnectReasonCodeConverter.cs
浏览文件 @
0bb4c6ef
...
...
@@ -2,54 +2,12 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using
MQTTnet.Exceptions
;
using
MQTTnet.Protocol
;
namespace
MQTTnet.Formatter
{
public
static
class
MqttConnectReasonCodeConverter
{
public
static
MqttConnectReasonCode
ToConnectReasonCode
(
MqttConnectReturnCode
returnCode
)
{
switch
(
returnCode
)
{
case
MqttConnectReturnCode
.
ConnectionAccepted
:
{
return
MqttConnectReasonCode
.
Success
;
}
case
MqttConnectReturnCode
.
ConnectionRefusedUnacceptableProtocolVersion
:
{
return
MqttConnectReasonCode
.
UnsupportedProtocolVersion
;
}
case
MqttConnectReturnCode
.
ConnectionRefusedBadUsernameOrPassword
:
{
return
MqttConnectReasonCode
.
BadUserNameOrPassword
;
}
case
MqttConnectReturnCode
.
ConnectionRefusedIdentifierRejected
:
{
return
MqttConnectReasonCode
.
ClientIdentifierNotValid
;
}
case
MqttConnectReturnCode
.
ConnectionRefusedServerUnavailable
:
{
return
MqttConnectReasonCode
.
ServerUnavailable
;
}
case
MqttConnectReturnCode
.
ConnectionRefusedNotAuthorized
:
{
return
MqttConnectReasonCode
.
NotAuthorized
;
}
default
:
{
throw
new
MqttProtocolViolationException
(
"Unable to convert connect reason code (MQTTv5) to return code (MQTTv3)."
);
}
}
}
public
static
MqttConnectReturnCode
ToConnectReturnCode
(
MqttConnectReasonCode
reasonCode
)
{
switch
(
reasonCode
)
...
...
@@ -59,11 +17,13 @@ namespace MQTTnet.Formatter
return
MqttConnectReturnCode
.
ConnectionAccepted
;
}
case
MqttConnectReasonCode
.
Banned
:
case
MqttConnectReasonCode
.
NotAuthorized
:
{
return
MqttConnectReturnCode
.
ConnectionRefusedNotAuthorized
;
}
case
MqttConnectReasonCode
.
BadAuthenticationMethod
:
case
MqttConnectReasonCode
.
BadUserNameOrPassword
:
{
return
MqttConnectReturnCode
.
ConnectionRefusedBadUsernameOrPassword
;
...
...
@@ -79,6 +39,7 @@ namespace MQTTnet.Formatter
return
MqttConnectReturnCode
.
ConnectionRefusedUnacceptableProtocolVersion
;
}
case
MqttConnectReasonCode
.
UseAnotherServer
:
case
MqttConnectReasonCode
.
ServerUnavailable
:
case
MqttConnectReasonCode
.
ServerBusy
:
case
MqttConnectReasonCode
.
ServerMoved
:
...
...
@@ -87,9 +48,7 @@ namespace MQTTnet.Formatter
}
default
:
{
throw
new
MqttProtocolViolationException
(
"Unable to convert connect reason code (MQTTv5) to return code (MQTTv3)."
);
}
return
MqttConnectReturnCode
.
ConnectionRefusedUnacceptableProtocolVersion
;
}
}
}
...
...
Source/MQTTnet/Formatter/V5/MqttV5PacketDecoder.cs
浏览文件 @
0bb4c6ef
...
...
@@ -130,6 +130,9 @@ namespace MQTTnet.Formatter.V5
MaximumQoS
=
MqttQualityOfServiceLevel
.
ExactlyOnce
};
// Also set the return code of MQTT 3.1.1 for backward compatibility and debugging purposes.
packet
.
ReturnCode
=
MqttConnectReasonCodeConverter
.
ToConnectReturnCode
(
packet
.
ReasonCode
);
var
propertiesReader
=
new
MqttV5PropertiesReader
(
_bufferReader
);
while
(
propertiesReader
.
MoveNext
())
{
...
...
Source/MQTTnet/Implementations/MqttTcpChannel.cs
浏览文件 @
0bb4c6ef
...
...
@@ -100,6 +100,12 @@ namespace MQTTnet.Implementations
if
(
_tcpOptions
.
TlsOptions
?.
UseTls
==
true
)
{
var
targetHost
=
_tcpOptions
.
TlsOptions
.
TargetHost
;
if
(
string
.
IsNullOrEmpty
(
targetHost
))
{
targetHost
=
_tcpOptions
.
Server
;
}
var
sslStream
=
new
SslStream
(
networkStream
,
false
,
InternalUserCertificateValidationCallback
);
try
{
...
...
@@ -111,14 +117,16 @@ namespace MQTTnet.Implementations
EnabledSslProtocols
=
_tcpOptions
.
TlsOptions
.
SslProtocol
,
CertificateRevocationCheckMode
=
_tcpOptions
.
TlsOptions
.
IgnoreCertificateRevocationErrors
?
X509RevocationMode
.
NoCheck
:
_tcpOptions
.
TlsOptions
.
RevocationMode
,
TargetHost
=
_tcpOptions
.
Server
,
CipherSuitesPolicy
=
_tcpOptions
.
TlsOptions
.
CipherSuitesPolicy
TargetHost
=
targetHost
,
CipherSuitesPolicy
=
_tcpOptions
.
TlsOptions
.
CipherSuitesPolicy
,
EncryptionPolicy
=
_tcpOptions
.
TlsOptions
.
EncryptionPolicy
,
AllowRenegotiation
=
_tcpOptions
.
TlsOptions
.
AllowRenegotiation
};
await
sslStream
.
AuthenticateAsClientAsync
(
sslOptions
,
cancellationToken
).
ConfigureAwait
(
false
);
#else
await
sslStream
.
AuthenticateAsClientAsync
(
_tcpOptions
.
Server
,
targetHost
,
LoadCertificates
(),
_tcpOptions
.
TlsOptions
.
SslProtocol
,
!
_tcpOptions
.
TlsOptions
.
IgnoreCertificateRevocationErrors
)
...
...
@@ -290,12 +298,12 @@ namespace MQTTnet.Implementations
X509CertificateCollection
LoadCertificates
()
{
var
certificates
=
new
X509CertificateCollection
();
if
(
_tcpOptions
.
TlsOptions
.
Certificates
==
null
)
{
return
certificates
;
return
null
;
}
var
certificates
=
new
X509CertificateCollection
();
foreach
(
var
certificate
in
_tcpOptions
.
TlsOptions
.
Certificates
)
{
certificates
.
Add
(
certificate
);
...
...
Source/MQTTnet/Implementations/MqttWebSocketChannel.cs
浏览文件 @
0bb4c6ef
...
...
@@ -220,6 +220,8 @@ namespace MQTTnet.Implementations
throw
new
NotSupportedException
(
"Remote certificate validation callback is not supported when using 'net452'."
);
#elif NET461
throw
new
NotSupportedException
(
"Remote certificate validation callback is not supported when using 'net461'."
);
#elif NET48
throw
new
NotSupportedException
(
"Remote certificate validation callback is not supported when using 'net48'."
);
#else
clientWebSocket
.
Options
.
RemoteCertificateValidationCallback
=
(
sender
,
certificate
,
chain
,
sslPolicyErrors
)
=>
{
...
...
Source/MQTTnet/MQTTnet.csproj
浏览文件 @
0bb4c6ef
...
...
@@ -11,7 +11,7 @@
<PropertyGroup>
<TargetFrameworks>netstandard1.3;netstandard2.0;netstandard2.1;netcoreapp3.1;net5.0;net6.0;net7.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net452;net461</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net452;net461
;net48
</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' AND '$(MSBuildRuntimeType)' != 'Core' ">$(TargetFrameworks);uap10.0</TargetFrameworks>
<LangVersion>7.3</LangVersion>
<AssemblyName>MQTTnet</AssemblyName>
...
...
Source/MQTTnet/Packets/MqttDisconnectPacket.cs
浏览文件 @
0bb4c6ef
...
...
@@ -36,7 +36,7 @@ namespace MQTTnet.Packets
public
override
string
ToString
()
{
return
$"Disconnect: [ReasonCode=
{
ReasonCode
}
]"
;
return
$"Disconnect: [ReasonCode=
{
ReasonCode
}
]
[ReasonString=
{
ReasonString
}
] [ServerReference=
{
ServerReference
}
] [SessionExpiryInterval=
{
SessionExpiryInterval
}
]
"
;
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录