@@ -46,8 +46,8 @@ public async Task ServerAsyncAuthenticate_EachSupportedProtocol_Success(SslProto
46
46
[ Theory ]
47
47
[ MemberData ( nameof ( ProtocolMismatchData ) ) ]
48
48
public async Task ServerAsyncAuthenticate_MismatchProtocols_Fails (
49
- SslProtocols serverProtocol ,
50
49
SslProtocols clientProtocol ,
50
+ SslProtocols serverProtocol ,
51
51
Type expectedException )
52
52
{
53
53
Exception e = await Record . ExceptionAsync (
@@ -236,7 +236,7 @@ public async Task ServerAsyncAuthenticate_ConstructorVerificationDelegate_Succes
236
236
237
237
( Stream clientStream , Stream serverStream ) = TestHelper . GetConnectedStreams ( ) ;
238
238
var client = new SslStream ( clientStream ) ;
239
- var server = new SslStream ( serverStream , false , ( sender , certificate , chain , sslPolicyErrors ) => { validationCallbackCalled = true ; return true ; } ) ;
239
+ var server = new SslStream ( serverStream , false , ( sender , certificate , chain , sslPolicyErrors ) => { validationCallbackCalled = true ; return true ; } ) ;
240
240
241
241
using ( client )
242
242
using ( server )
@@ -323,37 +323,18 @@ public async Task ServerAsyncAuthenticate_InvalidHello_Throws(bool close)
323
323
324
324
public static IEnumerable < object [ ] > ProtocolMismatchData ( )
325
325
{
326
- if ( PlatformDetection . SupportsSsl3 )
327
- {
328
- #pragma warning disable 0618
329
- yield return new object [ ] { SslProtocols . Ssl3 , SslProtocols . Tls12 , typeof ( Exception ) } ;
330
- if ( PlatformDetection . SupportsSsl2 )
331
- {
332
- yield return new object [ ] { SslProtocols . Ssl2 , SslProtocols . Ssl3 , typeof ( Exception ) } ;
333
- yield return new object [ ] { SslProtocols . Ssl2 , SslProtocols . Tls12 , typeof ( Exception ) } ;
334
- }
335
- #pragma warning restore 0618
336
- }
337
-
338
- // It is OK if server does not support given protocol. It should still fail.
339
- // But if client does not support it, it will simply fail without sending out any data.
340
-
341
- if ( PlatformDetection . SupportsTls10 )
342
- {
343
- yield return new object [ ] { SslProtocols . Tls11 , SslProtocols . Tls , typeof ( AuthenticationException ) } ;
344
- yield return new object [ ] { SslProtocols . Tls12 , SslProtocols . Tls , typeof ( AuthenticationException ) } ;
345
- }
326
+ var supportedProtocols = new SslProtocolSupport . SupportedSslProtocolsTestData ( ) ;
346
327
347
- if ( PlatformDetection . SupportsTls11 )
328
+ foreach ( var serverProtocols in supportedProtocols )
329
+ foreach ( var clientProtocols in supportedProtocols )
348
330
{
349
- yield return new object [ ] { SslProtocols . Tls , SslProtocols . Tls11 , typeof ( AuthenticationException ) } ;
350
- yield return new object [ ] { SslProtocols . Tls12 , SslProtocols . Tls11 , typeof ( AuthenticationException ) } ;
351
- }
331
+ SslProtocols serverProtocol = ( SslProtocols ) serverProtocols [ 0 ] ;
332
+ SslProtocols clientProtocol = ( SslProtocols ) clientProtocols [ 0 ] ;
352
333
353
- if ( PlatformDetection . SupportsTls12 )
354
- {
355
- yield return new object [ ] { SslProtocols . Tls , SslProtocols . Tls12 , typeof ( AuthenticationException ) } ;
356
- yield return new object [ ] { SslProtocols . Tls11 , SslProtocols . Tls12 , typeof ( AuthenticationException ) } ;
334
+ if ( clientProtocol != serverProtocol )
335
+ {
336
+ yield return new object [ ] { clientProtocol , serverProtocol , typeof ( AuthenticationException ) } ;
337
+ }
357
338
}
358
339
}
359
340
0 commit comments