@@ -862,6 +862,7 @@ public async Task SslStream_ClientCertificate_SendsChain()
862
862
List < SslStream > streams = new List < SslStream > ( ) ;
863
863
TestHelper . CleanupCertificates ( ) ;
864
864
( X509Certificate2 clientCertificate , X509Certificate2Collection clientChain ) = TestHelper . GenerateCertificates ( "SslStream_ClinetCertificate_SendsChain" , serverCertificate : false ) ;
865
+
865
866
using ( X509Store store = new X509Store ( StoreName . CertificateAuthority , StoreLocation . CurrentUser ) )
866
867
{
867
868
// add chain certificate so we can construct chain since there is no way how to pass intermediates directly.
@@ -883,7 +884,7 @@ public async Task SslStream_ClientCertificate_SendsChain()
883
884
}
884
885
}
885
886
886
- var clientOptions = new SslClientAuthenticationOptions ( ) { TargetHost = "localhost" , } ;
887
+ var clientOptions = new SslClientAuthenticationOptions ( ) { TargetHost = "localhost" } ;
887
888
clientOptions . RemoteCertificateValidationCallback = ( sender , certificate , chain , sslPolicyErrors ) => true ;
888
889
clientOptions . LocalCertificateSelectionCallback = ( sender , target , certificates , remoteCertificate , issuers ) => clientCertificate ;
889
890
@@ -900,7 +901,8 @@ public async Task SslStream_ClientCertificate_SendsChain()
900
901
_output . WriteLine ( "received {0}" , c . Subject ) ;
901
902
}
902
903
903
- Assert . True ( chain . ChainPolicy . ExtraStore . Count >= clientChain . Count - 1 , "client did not sent expected chain" ) ;
904
+ Assert . Equal ( clientChain . Count - 1 , chain . ChainPolicy . ExtraStore . Count ) ;
905
+ Assert . Contains ( clientChain [ 0 ] , chain . ChainPolicy . ExtraStore ) ;
904
906
return true ;
905
907
} ;
906
908
@@ -913,7 +915,7 @@ public async Task SslStream_ClientCertificate_SendsChain()
913
915
914
916
Task t1 = client . AuthenticateAsClientAsync ( clientOptions , CancellationToken . None ) ;
915
917
Task t2 = server . AuthenticateAsServerAsync ( serverOptions , CancellationToken . None ) ;
916
- await Task . WhenAll ( t1 , t2 ) . WaitAsync ( TestConfiguration . PassingTestTimeout ) ;
918
+ await TestConfiguration . WhenAllOrAnyFailedWithTimeout ( t1 , t2 ) ;
917
919
918
920
// hold to the streams so they stay in credential cache
919
921
streams . Add ( client ) ;
0 commit comments