Skip to content

Commit 20270ed

Browse files
committed
fixed the units about tls
1 parent 9315ff5 commit 20270ed

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

test/SuperSocket.Tests/MainTest.cs

+1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ public void TestCustomConfigOptions()
101101

102102
[Theory]
103103
[InlineData("Tls12", SslProtocols.Tls12, false)]
104+
//[InlineData("Tls13", SslProtocols.Tls13, false)] We cannot test it because TLS 1.3 client is only available in Windows
104105
[InlineData("Tls15", SslProtocols.None, true)]
105106
[InlineData("Tls13, Tls12", SslProtocols.Tls13 | SslProtocols.Tls12, false)]
106107
[InlineData("Tls13,Tls12", SslProtocols.Tls13 | SslProtocols.Tls12, false)]

test/SuperSocket.Tests/SecureHostConfigurator.cs

+18-6
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ namespace SuperSocket.Tests
2020
{
2121
public class SecureHostConfigurator : TcpHostConfigurator
2222
{
23+
private SslProtocols _currentSslProtocols;
24+
2325
public SecureHostConfigurator()
2426
{
2527
WebSocketSchema = "wss";
@@ -34,12 +36,22 @@ public override void Configure(ISuperSocketHostBuilder hostBuilder)
3436
{
3537
var listener = options.Listeners[0];
3638

37-
listener.AuthenticationOptions = new ServerAuthenticationOptions
39+
var authenticationOptions = listener.AuthenticationOptions;
40+
41+
if (authenticationOptions == null)
3842
{
39-
FilePath = "supersocket.pfx",
40-
Password = "supersocket",
41-
EnabledSslProtocols = GetServerEnabledSslProtocols()
42-
};
43+
authenticationOptions = listener.AuthenticationOptions = new ServerAuthenticationOptions();
44+
}
45+
46+
authenticationOptions.FilePath = "supersocket.pfx";
47+
authenticationOptions.Password = "supersocket";
48+
49+
if (authenticationOptions.EnabledSslProtocols == SslProtocols.None)
50+
{
51+
authenticationOptions.EnabledSslProtocols = GetServerEnabledSslProtocols();
52+
}
53+
54+
_currentSslProtocols = authenticationOptions.EnabledSslProtocols;
4355
});
4456
});
4557

@@ -63,7 +75,7 @@ protected virtual SslProtocols GetServerEnabledSslProtocols()
6375

6476
protected virtual SslProtocols GetClientEnabledSslProtocols()
6577
{
66-
return SslProtocols.Tls13 | SslProtocols.Tls12;
78+
return _currentSslProtocols;
6779
}
6880

6981
public override IEasyClient<TPackageInfo> ConfigureEasyClient<TPackageInfo>(IPipelineFilter<TPackageInfo> pipelineFilter, ConnectionOptions options)

0 commit comments

Comments
 (0)