Skip to content

Commit b8f1a06

Browse files
authored
Mark SslProtocols.Tls and SslProtocols.Tls11 as obsolete (dotnet#65773)
Fixes dotnet#65546
1 parent 7e35e93 commit b8f1a06

34 files changed

+161
-34
lines changed

docs/project/list-of-diagnostics.md

+2
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ The PR that reveals the implementation of the `<IncludeInternalObsoleteAttribute
9292
| __`SYSLIB0035`__ | ComputeCounterSignature without specifying a CmsSigner is obsolete and is not supported. Use the overload that accepts a CmsSigner. |
9393
| __`SYSLIB0036`__ | Regex.CompileToAssembly is obsolete and not supported. Use RegexGeneratorAttribute with the regular expression source generator instead. |
9494
| __`SYSLIB0037`__ | AssemblyName members HashAlgorithm, ProcessorArchitecture, and VersionCompatibility are obsolete and not supported. |
95+
| __`SYSLIB0038`__ | SerializationFormat.Binary is obsolete and should not be used. See https://aka.ms/serializationformat-binary-obsolete for more information. |
96+
| __`SYSLIB0039`__ | TLS versions 1.0 and 1.1 have known vulnerabilities and are not recommended. Use a newer TLS version instead, or use SslProtocols.None to defer to OS defaults. |
9597

9698
## Analyzer Warnings
9799

src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.OpenSsl.cs

+2
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ private static SslProtocols CalculateEffectiveProtocols(SslAuthenticationOptions
9999
// we are using default settings but cipher suites policy says that TLS 1.3
100100
// is not compatible with our settings (i.e. we requested no encryption or disabled
101101
// all TLS 1.3 cipher suites)
102+
#pragma warning disable SYSLIB0039 // TLS 1.0 and 1.1 are obsolete
102103
protocols = SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12;
104+
#pragma warning restore SYSLIB0039
103105
}
104106
else
105107
{

src/libraries/Common/src/System/Net/SecurityProtocol.cs

+2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ internal static class SecurityProtocol
1111
#if !NETSTANDARD2_0 && !NETSTANDARD2_1 && !NETFRAMEWORK
1212
SslProtocols.Tls13 |
1313
#endif
14+
#pragma warning disable SYSLIB0039 // TLS 1.0 and 1.1 are obsolete
1415
SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12;
16+
#pragma warning restore SYSLIB0039
1517

1618
public const SslProtocols SystemDefaultSecurityProtocols = SslProtocols.None;
1719
}

src/libraries/Common/src/System/Obsoletions.cs

+3
Original file line numberDiff line numberDiff line change
@@ -126,5 +126,8 @@ internal static class Obsoletions
126126

127127
internal const string SystemDataSerializationFormatBinaryMessage = "SerializationFormat.Binary is obsolete and should not be used. See https://aka.ms/serializationformat-binary-obsolete for more information.";
128128
internal const string SystemDataSerializationFormatBinaryDiagId = "SYSLIB0038";
129+
130+
internal const string TlsVersion10and11Message = "TLS versions 1.0 and 1.1 have known vulnerabilities and are not recommended. Use a newer TLS version instead, or use SslProtocols.None to defer to OS defaults.";
131+
internal const string TlsVersion10and11DiagId = "SYSLIB0039";
129132
}
130133
}

src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.AcceptAllCerts.cs

+6
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,23 @@ public void SingletonReturnsTrue()
3636
[Theory]
3737
[InlineData(SslProtocols.Tls12, false)] // try various protocols to ensure we correctly set versions even when accepting all certs
3838
[InlineData(SslProtocols.Tls12, true)]
39+
#pragma warning disable SYSLIB0039 // TLS 1.0 and 1.1 are obsolete
3940
[InlineData(SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls, false)]
4041
[InlineData(SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls, true)]
4142
#if !NETFRAMEWORK
4243
[InlineData(SslProtocols.Tls13 | SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls, false)]
4344
[InlineData(SslProtocols.Tls13 | SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls, true)]
4445
#endif
46+
#pragma warning restore SYSLIB0039
4547
[InlineData(SslProtocols.None, false)]
4648
[InlineData(SslProtocols.None, true)]
4749
public async Task SetDelegate_ConnectionSucceeds(SslProtocols acceptedProtocol, bool requestOnlyThisProtocol)
4850
{
51+
#pragma warning disable SYSLIB0039 // TLS 1.0 and 1.1 are obsolete
4952
// Overriding flag for the same reason we skip tests on Catalina
5053
// On OSX 10.13-10.14 we can override this flag to enable the scenario
5154
requestOnlyThisProtocol |= PlatformDetection.IsOSX && acceptedProtocol == SslProtocols.Tls;
55+
#pragma warning restore SYSLIB0039
5256

5357
using (HttpClientHandler handler = CreateHttpClientHandler())
5458
using (HttpClient client = CreateHttpClient(handler))
@@ -65,11 +69,13 @@ public async Task SetDelegate_ConnectionSucceeds(SslProtocols acceptedProtocol,
6569
// restrictions on minimum TLS/SSL version
6670
// We currently know that some platforms like Debian 10 OpenSSL
6771
// will by default block < TLS 1.2
72+
#pragma warning disable SYSLIB0039 // TLS 1.0 and 1.1 are obsolete
6873
#if !NETFRAMEWORK
6974
handler.SslProtocols = SslProtocols.Tls13 | SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls;
7075
#else
7176
handler.SslProtocols = SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls;
7277
#endif
78+
#pragma warning restore SYSLIB0039
7379
}
7480

7581
var options = new LoopbackServer.Options { UseSsl = true, SslProtocols = acceptedProtocol };

src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.SslProtocols.cs

+10
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public void DefaultProtocols_MatchesExpected()
3636

3737
[Theory]
3838
[InlineData(SslProtocols.None)]
39+
#pragma warning disable SYSLIB0039 // TLS 1.0 and 1.1 are obsolete
3940
[InlineData(SslProtocols.Tls)]
4041
[InlineData(SslProtocols.Tls11)]
4142
[InlineData(SslProtocols.Tls12)]
@@ -50,6 +51,7 @@ public void DefaultProtocols_MatchesExpected()
5051
[InlineData(SslProtocols.Tls | SslProtocols.Tls13)]
5152
[InlineData(SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12 | SslProtocols.Tls13)]
5253
#endif
54+
#pragma warning restore SYSLIB0039
5355
public void SetGetProtocols_Roundtrips(SslProtocols protocols)
5456
{
5557
using (HttpClientHandler handler = CreateHttpClientHandler())
@@ -119,12 +121,14 @@ public async Task GetAsync_AllowedSSLVersion_Succeeds(SslProtocols acceptedProto
119121
// We currently know that some platforms like Debian 10 OpenSSL
120122
// will by default block < TLS 1.2
121123
#pragma warning disable 0618 // SSL2/3 are deprecated
124+
#pragma warning disable SYSLIB0039 // TLS 1.0 and 1.1 are obsolete
122125
#if !NETFRAMEWORK
123126
handler.SslProtocols = SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12 | SslProtocols.Tls13;
124127
#else
125128
handler.SslProtocols = SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12 | (SslProtocols)12288;
126129
#endif
127130
#pragma warning restore 0618
131+
#pragma warning restore SYSLIB0039
128132
}
129133

130134
// Use a different SNI for each connection to prevent TLS 1.3 renegotiation issue: https://github.com/dotnet/runtime/issues/47378
@@ -162,6 +166,7 @@ public static IEnumerable<object[]> SupportedSSLVersionServers()
162166
yield return new object[] { SslProtocols.Ssl3, Configuration.Http.SSLv3RemoteServer };
163167
}
164168
#pragma warning restore 0618
169+
#pragma warning disable SYSLIB0039 // TLS 1.0 and 1.1 are obsolete
165170
if (PlatformDetection.SupportsTls10)
166171
{
167172
yield return new object[] { SslProtocols.Tls, Configuration.Http.TLSv10RemoteServer };
@@ -171,6 +176,7 @@ public static IEnumerable<object[]> SupportedSSLVersionServers()
171176
{
172177
yield return new object[] { SslProtocols.Tls11, Configuration.Http.TLSv11RemoteServer };
173178
}
179+
#pragma warning restore SYSLIB0039
174180

175181
if (PlatformDetection.SupportsTls12)
176182
{
@@ -262,16 +268,20 @@ await TestHelper.WhenAllCompletedOrAnyFailed(
262268
[InlineData(SslProtocols.Ssl2, SslProtocols.Tls12)]
263269
[InlineData(SslProtocols.Ssl3, SslProtocols.Tls12)]
264270
#pragma warning restore 0618
271+
#pragma warning disable SYSLIB0039 // TLS 1.0 and 1.1 are obsolete
265272
[InlineData(SslProtocols.Tls11, SslProtocols.Tls)]
266273
[InlineData(SslProtocols.Tls11 | SslProtocols.Tls12, SslProtocols.Tls)] // Skip this on WinHttpHandler.
267274
[InlineData(SslProtocols.Tls12, SslProtocols.Tls11)]
268275
[InlineData(SslProtocols.Tls, SslProtocols.Tls12)]
276+
#pragma warning restore SYSLIB0039
269277
public async Task GetAsync_AllowedClientSslVersionDiffersFromServer_ThrowsException(
270278
SslProtocols allowedClientProtocols, SslProtocols acceptedServerProtocols)
271279
{
280+
#pragma warning disable SYSLIB0039 // TLS 1.0 and 1.1 are obsolete
272281
if (IsWinHttpHandler &&
273282
allowedClientProtocols == (SslProtocols.Tls11 | SslProtocols.Tls12) &&
274283
acceptedServerProtocols == SslProtocols.Tls)
284+
#pragma warning restore SYSLIB0039
275285
{
276286
// Native WinHTTP sometimes uses multiple TCP connections to try other TLS protocols when
277287
// getting TLS protocol failures as part of its TLS fallback algorithm. The loopback server

src/libraries/Common/tests/System/Net/Http/LoopbackServer.cs

+2
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,9 @@ public Options()
436436
#if !NETSTANDARD2_0 && !NETFRAMEWORK
437437
SslProtocols.Tls13 |
438438
#endif
439+
#pragma warning disable SYSLIB0039 // TLS 1.0 and 1.1 are obsolete
439440
SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12;
441+
#pragma warning restore SYSLIB0039
440442
}
441443
}
442444

src/libraries/Common/tests/System/Net/SslProtocolSupport.cs

+4
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ public class SslProtocolSupport
1414
#if !NETSTANDARD2_0
1515
SslProtocols.Tls13 |
1616
#endif
17+
#pragma warning disable SYSLIB0039 // TLS 1.0 and 1.1 are obsolete
1718
SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls;
1819

1920
public const SslProtocols NonTls13Protocols = SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12;
21+
#pragma warning restore SYSLIB0039
2022

2123
public static SslProtocols SupportedSslProtocols
2224
{
@@ -29,6 +31,7 @@ public static SslProtocols SupportedSslProtocols
2931
supported |= SslProtocols.Ssl3;
3032
}
3133
#pragma warning restore 0618
34+
#pragma warning disable SYSLIB0039 // TLS 1.0 and 1.1 are obsolete
3235
if (PlatformDetection.SupportsTls10)
3336
{
3437
supported |= SslProtocols.Tls;
@@ -38,6 +41,7 @@ public static SslProtocols SupportedSslProtocols
3841
{
3942
supported |= SslProtocols.Tls11;
4043
}
44+
#pragma warning restore SYSLIB0039
4145

4246
if (PlatformDetection.SupportsTls12)
4347
{

src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpHandler.cs

+2
Original file line numberDiff line numberDiff line change
@@ -1188,6 +1188,7 @@ private void SetSessionHandleTlsOptions(SafeWinHttpHandle sessionHandle)
11881188
}
11891189
#pragma warning restore 0618
11901190

1191+
#pragma warning disable SYSLIB0039 // TLS 1.0 and 1.1 are obsolete
11911192
if ((sslProtocols & SslProtocols.Tls) != 0)
11921193
{
11931194
optionData |= Interop.WinHttp.WINHTTP_FLAG_SECURE_PROTOCOL_TLS1;
@@ -1197,6 +1198,7 @@ private void SetSessionHandleTlsOptions(SafeWinHttpHandle sessionHandle)
11971198
{
11981199
optionData |= Interop.WinHttp.WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_1;
11991200
}
1201+
#pragma warning restore SYSLIB0039
12001202

12011203
if ((sslProtocols & SslProtocols.Tls12) != 0)
12021204
{

src/libraries/System.Net.Http.WinHttpHandler/tests/UnitTests/WinHttpHandlerTest.cs

+2
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,9 @@ public void SslProtocols_SetUsingNone_Success()
562562

563563
[Theory]
564564
[InlineData(
565+
#pragma warning disable SYSLIB0039 // TLS 1.0 and 1.1 are obsolete
565566
SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12,
567+
#pragma warning restore SYSLIB0039
566568
Interop.WinHttp.WINHTTP_FLAG_SECURE_PROTOCOL_TLS1 |
567569
Interop.WinHttp.WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_1 |
568570
Interop.WinHttp.WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2)]

src/libraries/System.Net.Primitives/ref/System.Net.Primitives.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -516,9 +516,11 @@ public enum SslProtocols
516516
Ssl2 = 12,
517517
[System.ObsoleteAttribute("SslProtocols.Ssl3 has been deprecated and is not supported.")]
518518
Ssl3 = 48,
519+
[System.ObsoleteAttribute("TLS versions 1.0 and 1.1 have known vulnerabilities and are not recommended. Use a newer TLS version instead, or use SslProtocols.None to defer to OS defaults.", DiagnosticId = "SYSLIB0039", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
519520
Tls = 192,
520521
[System.ObsoleteAttribute("SslProtocols.Default has been deprecated and is not supported.")]
521522
Default = 240,
523+
[System.ObsoleteAttribute("TLS versions 1.0 and 1.1 have known vulnerabilities and are not recommended. Use a newer TLS version instead, or use SslProtocols.None to defer to OS defaults.", DiagnosticId = "SYSLIB0039", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
522524
Tls11 = 768,
523525
Tls12 = 3072,
524526
Tls13 = 12288,
@@ -528,8 +530,8 @@ namespace System.Security.Authentication.ExtendedProtection
528530
{
529531
public abstract partial class ChannelBinding : Microsoft.Win32.SafeHandles.SafeHandleZeroOrMinusOneIsInvalid
530532
{
531-
protected ChannelBinding() : base (default(bool)) { }
532-
protected ChannelBinding(bool ownsHandle) : base (default(bool)) { }
533+
protected ChannelBinding() : base(default(bool)) { }
534+
protected ChannelBinding(bool ownsHandle) : base(default(bool)) { }
533535
public abstract int Size { get; }
534536
}
535537
public enum ChannelBindingKind

src/libraries/System.Net.Primitives/src/System.Net.Primitives.csproj

+3
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@
8686
Link="Common\Interop\Windows\SChannel\Interop.SchProtocols.cs" />
8787
<Compile Include="$(CommonPath)Interop\Windows\WinSock\Interop.ErrorCodes.cs"
8888
Link="Common\Interop\Windows\WinSock\Interop.ErrorCodes.cs" />
89+
<!-- Common -->
90+
<Compile Include="$(CommonPath)System\Obsoletions.cs"
91+
Link="Common\System\Obsoletions.cs" />
8992
</ItemGroup>
9093
<ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'windows'">
9194
<Compile Include="System\Net\SocketException.Windows.cs" />

src/libraries/System.Net.Primitives/src/System/Net/SecureProtocols/SslEnumTypes.cs

+5
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,17 @@ namespace System.Security.Authentication
1010
public enum SslProtocols
1111
{
1212
None = 0,
13+
[System.ObsoleteAttribute("SslProtocols.Ssl2 has been deprecated and is not supported.")]
1314
Ssl2 = Interop.SChannel.SP_PROT_SSL2,
15+
[System.ObsoleteAttribute("SslProtocols.Ssl3 has been deprecated and is not supported.")]
1416
Ssl3 = Interop.SChannel.SP_PROT_SSL3,
17+
[System.ObsoleteAttribute(Obsoletions.TlsVersion10and11Message, DiagnosticId = Obsoletions.TlsVersion10and11DiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
1518
Tls = Interop.SChannel.SP_PROT_TLS1_0,
19+
[System.ObsoleteAttribute(Obsoletions.TlsVersion10and11Message, DiagnosticId = Obsoletions.TlsVersion10and11DiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
1620
Tls11 = Interop.SChannel.SP_PROT_TLS1_1,
1721
Tls12 = Interop.SChannel.SP_PROT_TLS1_2,
1822
Tls13 = Interop.SChannel.SP_PROT_TLS1_3,
23+
[System.ObsoleteAttribute("SslProtocols.Default has been deprecated and is not supported.")]
1924
Default = Ssl3 | Tls
2025
}
2126

src/libraries/System.Net.Security/src/System.Net.Security.csproj

+2
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@
9494
Link="Common\System\Net\SecurityStatusPal.cs" />
9595
<Compile Include="$(CommonPath)System\HexConverter.cs"
9696
Link="Common\System\HexConverter.cs" />
97+
<Compile Include="$(CommonPath)System\Obsoletions.cs"
98+
Link="Common\System\Obsoletions.cs" />
9799
</ItemGroup>
98100
<!-- This file depends on IANA registry. We do not want anyone's build to break after the update -->
99101
<!-- or if they don't have internet connection - explicit opt-in required -->

src/libraries/System.Net.Security/src/System/Net/Security/NetSecurityTelemetry.cs

+4
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ public void HandshakeCompleted(SslProtocols protocol, ValueStopwatch stopwatch,
179179

180180
switch (protocol)
181181
{
182+
#pragma warning disable SYSLIB0039 // TLS 1.0 and 1.1 are obsolete
182183
case SslProtocols.Tls:
183184
protocolSessionsOpen = ref _sessionsOpenTls10;
184185
handshakeDurationCounter = _handshakeDurationTls10Counter;
@@ -188,6 +189,7 @@ public void HandshakeCompleted(SslProtocols protocol, ValueStopwatch stopwatch,
188189
protocolSessionsOpen = ref _sessionsOpenTls11;
189190
handshakeDurationCounter = _handshakeDurationTls11Counter;
190191
break;
192+
#pragma warning restore SYSLIB0039
191193

192194
case SslProtocols.Tls12:
193195
protocolSessionsOpen = ref _sessionsOpenTls12;
@@ -220,13 +222,15 @@ public void ConnectionClosed(SslProtocols protocol)
220222

221223
switch (protocol)
222224
{
225+
#pragma warning disable SYSLIB0039 // TLS 1.0 and 1.1 are obsolete
223226
case SslProtocols.Tls:
224227
count = Interlocked.Decrement(ref _sessionsOpenTls10);
225228
break;
226229

227230
case SslProtocols.Tls11:
228231
count = Interlocked.Decrement(ref _sessionsOpenTls11);
229232
break;
233+
#pragma warning restore SYSLIB0039
230234

231235
case SslProtocols.Tls12:
232236
count = Interlocked.Decrement(ref _sessionsOpenTls12);

src/libraries/System.Net.Security/src/System/Net/Security/Pal.Android/SafeDeleteSslContext.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ internal sealed class SafeDeleteSslContext : SafeDeleteContext
2222
private const int InitialBufferSize = 2048;
2323
private static readonly SslProtocols[] s_orderedSslProtocols = new SslProtocols[]
2424
{
25+
#pragma warning disable SYSLIB0039 // TLS 1.0 and 1.1 are obsolete
2526
SslProtocols.Tls,
2627
SslProtocols.Tls11,
28+
#pragma warning restore SYSLIB0039
2729
SslProtocols.Tls12,
2830
SslProtocols.Tls13,
2931
};
@@ -224,7 +226,7 @@ private static void InitializeSslContext(
224226
Interop.AndroidCrypto.SSLStreamInitialize(handle, isServer, readCallback, writeCallback, InitialBufferSize);
225227

226228
if (credential.Protocols != SslProtocols.None)
227-
{;
229+
{
228230
SslProtocols protocolsToEnable = credential.Protocols & s_supportedSslProtocols.Value;
229231
if (protocolsToEnable == 0)
230232
{

src/libraries/System.Net.Security/src/System/Net/Security/Pal.OSX/SafeDeleteSslContext.cs

+2
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,10 @@ internal int ReadPendingWrites(byte[] buf, int offset, int count)
339339
SslProtocols.Ssl2,
340340
SslProtocols.Ssl3,
341341
#pragma warning restore 0618
342+
#pragma warning disable SYSLIB0039 // TLS 1.0 and 1.1 are obsolete
342343
SslProtocols.Tls,
343344
SslProtocols.Tls11,
345+
#pragma warning restore SYSLIB0039
344346
SslProtocols.Tls12
345347
};
346348

src/libraries/System.Net.Security/src/System/Net/Security/SslConnectionInfo.Android.cs

+2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ public SslConnectionInfo(SafeSslHandle sslContext)
1717
#pragma warning disable 0618 // 'SslProtocols.Ssl3' is obsolete
1818
"SSLv3" => SslProtocols.Ssl3,
1919
#pragma warning restore
20+
#pragma warning disable SYSLIB0039 // TLS 1.0 and 1.1 are obsolete
2021
"TLSv1" => SslProtocols.Tls,
2122
"TLSv1.1" => SslProtocols.Tls11,
23+
#pragma warning restore SYSLIB0039
2224
"TLSv1.2" => SslProtocols.Tls12,
2325
"TLSv1.3" => SslProtocols.Tls13,
2426
_ => SslProtocols.None,

src/libraries/System.Net.Security/src/System/Net/Security/SslConnectionInfo.Linux.cs

+2
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,15 @@ private unsafe SslProtocols MapProtocolVersion(IntPtr protocolVersion)
4848
{
4949
if (b[5] == '\0')
5050
{
51+
#pragma warning disable SYSLIB0039 // TLS 1.0 and 1.1 are obsolete
5152
return SslProtocols.Tls;
5253
}
5354
else if (b[5] == '.' && b[6] != '\0' && b[7] == '\0')
5455
{
5556
switch (b[6])
5657
{
5758
case (byte)'1': return SslProtocols.Tls11;
59+
#pragma warning restore SYSLIB0039
5860
case (byte)'2': return SslProtocols.Tls12;
5961
case (byte)'3': return SslProtocols.Tls13;
6062
}

src/libraries/System.Net.Security/src/System/Net/Security/SslStream.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -455,8 +455,8 @@ public virtual Task AuthenticateAsClientAsync(string targetHost, X509Certificate
455455
{
456456
SslClientAuthenticationOptions options = new SslClientAuthenticationOptions()
457457
{
458-
TargetHost = targetHost,
459-
ClientCertificates = clientCertificates,
458+
TargetHost = targetHost,
459+
ClientCertificates = clientCertificates,
460460
EnabledSslProtocols = enabledSslProtocols,
461461
CertificateRevocationCheckMode = checkCertificateRevocation ? X509RevocationMode.Online : X509RevocationMode.NoCheck,
462462
EncryptionPolicy = _encryptionPolicy,
@@ -600,6 +600,7 @@ private SslProtocols GetSslProtocolInternal()
600600
}
601601
#pragma warning restore
602602

603+
#pragma warning disable SYSLIB0039 // TLS 1.0 and 1.1 are obsolete
603604
if ((proto & SslProtocols.Tls) != 0)
604605
{
605606
ret |= SslProtocols.Tls;
@@ -609,6 +610,7 @@ private SslProtocols GetSslProtocolInternal()
609610
{
610611
ret |= SslProtocols.Tls11;
611612
}
613+
#pragma warning restore SYSLIB0039
612614

613615
if ((proto & SslProtocols.Tls12) != 0)
614616
{

0 commit comments

Comments
 (0)