@@ -240,19 +240,12 @@ await TestHelper.WhenAllCompletedOrAnyFailed(
240240
241241 [ OuterLoop ] // TODO: Issue #11345
242242 [ Theory ]
243- [ InlineData ( SslProtocols . Tls11 , SslProtocols . Tls , typeof ( IOException ) ) ]
244- [ InlineData ( SslProtocols . Tls12 , SslProtocols . Tls11 , typeof ( IOException ) ) ]
245- [ InlineData ( SslProtocols . Tls , SslProtocols . Tls12 , typeof ( AuthenticationException ) ) ]
243+ [ InlineData ( SslProtocols . Tls11 , SslProtocols . Tls ) ]
244+ [ InlineData ( SslProtocols . Tls12 , SslProtocols . Tls11 ) ]
245+ [ InlineData ( SslProtocols . Tls , SslProtocols . Tls12 ) ]
246246 public async Task GetAsync_AllowedSSLVersionDiffersFromServer_ThrowsException (
247- SslProtocols allowedProtocol , SslProtocols acceptedProtocol , Type exceptedServerException )
247+ SslProtocols allowedProtocol , SslProtocols acceptedProtocol )
248248 {
249-
250- if ( PlatformDetection . IsUbuntu1804 )
251- {
252- //ActiveIssue #27023: [Ubuntu18.04] Tests failed:
253- return ;
254- }
255-
256249 if ( ! BackendSupportsSslConfiguration )
257250 return ;
258251 using ( HttpClientHandler handler = CreateHttpClientHandler ( ) )
@@ -264,9 +257,20 @@ public async Task GetAsync_AllowedSSLVersionDiffersFromServer_ThrowsException(
264257 var options = new LoopbackServer . Options { UseSsl = true , SslProtocols = acceptedProtocol } ;
265258 await LoopbackServer . CreateServerAsync ( async ( server , url ) =>
266259 {
267- await TestHelper . WhenAllCompletedOrAnyFailed (
268- Assert . ThrowsAsync ( exceptedServerException , ( ) => server . AcceptConnectionSendResponseAndCloseAsync ( ) ) ,
269- Assert . ThrowsAsync < HttpRequestException > ( ( ) => client . GetAsync ( url ) ) ) ;
260+ Task serverTask = server . AcceptConnectionSendResponseAndCloseAsync ( ) ;
261+ await Assert . ThrowsAsync < HttpRequestException > ( ( ) => client . GetAsync ( url ) ) ;
262+ try
263+ {
264+ await serverTask ;
265+ }
266+ catch ( Exception e ) when ( e is IOException || e is AuthenticationException )
267+ {
268+ // Some SSL implementations simply close or reset connection after protocol mismatch.
269+ // Newer OpenSSL sends Fatal Alert message before closing.
270+ return ;
271+ }
272+ // We expect negotiation to fail so one or the other expected exception should be thrown.
273+ Assert . True ( false , "Expected exception did not happen." ) ;
270274 } , options ) ;
271275 }
272276 }
@@ -276,12 +280,6 @@ await TestHelper.WhenAllCompletedOrAnyFailed(
276280 [ Fact ]
277281 public async Task GetAsync_DisallowTls10_AllowTls11_AllowTls12 ( )
278282 {
279- if ( PlatformDetection . IsUbuntu1804 )
280- {
281- //ActiveIssue #27023: [Ubuntu18.04] Tests failed:
282- return ;
283- }
284-
285283 using ( HttpClientHandler handler = CreateHttpClientHandler ( ) )
286284 using ( var client = new HttpClient ( handler ) )
287285 {
@@ -295,9 +293,20 @@ public async Task GetAsync_DisallowTls10_AllowTls11_AllowTls12()
295293 options . SslProtocols = SslProtocols . Tls ;
296294 await LoopbackServer . CreateServerAsync ( async ( server , url ) =>
297295 {
298- await TestHelper . WhenAllCompletedOrAnyFailed (
299- Assert . ThrowsAsync < IOException > ( ( ) => server . AcceptConnectionSendResponseAndCloseAsync ( ) ) ,
300- Assert . ThrowsAsync < HttpRequestException > ( ( ) => client . GetAsync ( url ) ) ) ;
296+ Task serverTask = server . AcceptConnectionSendResponseAndCloseAsync ( ) ;
297+ await Assert . ThrowsAsync < HttpRequestException > ( ( ) => client . GetAsync ( url ) ) ;
298+ try
299+ {
300+ await serverTask ;
301+ }
302+ catch ( Exception e ) when ( e is IOException || e is AuthenticationException )
303+ {
304+ // Some SSL implementations simply close or reset connection after protocol mismatch.
305+ // Newer OpenSSL sends Fatal Alert message before closing.
306+ return ;
307+ }
308+ // We expect negotiation to fail so one or the other expected exception should be thrown.
309+ Assert . True ( false , "Expected exception did not happen." ) ;
301310 } , options ) ;
302311
303312 foreach ( var prot in new [ ] { SslProtocols . Tls11 , SslProtocols . Tls12 } )
0 commit comments