@@ -319,6 +319,41 @@ public async Task VerifyValidClientCertWithTrustedChainAuthenticates()
319
319
Assert . Equal ( HttpStatusCode . OK , response . StatusCode ) ;
320
320
}
321
321
322
+ [ Fact ]
323
+ public async Task VerifyValidClientCertWithAdditionalCertificatesAuthenticates ( )
324
+ {
325
+ using var host = await CreateHost (
326
+ new CertificateAuthenticationOptions
327
+ {
328
+ Events = successfulValidationEvents ,
329
+ ChainTrustValidationMode = X509ChainTrustMode . CustomRootTrust ,
330
+ CustomTrustStore = new X509Certificate2Collection ( ) { Certificates . SelfSignedPrimaryRoot , } ,
331
+ AdditionalChainCertificates = new X509Certificate2Collection ( ) { Certificates . SignedSecondaryRoot } ,
332
+ RevocationMode = X509RevocationMode . NoCheck
333
+ } , Certificates . SignedClient ) ;
334
+
335
+ using var server = host . GetTestServer ( ) ;
336
+ var response = await server . CreateClient ( ) . GetAsync ( "https://example.com/" ) ;
337
+ Assert . Equal ( HttpStatusCode . OK , response . StatusCode ) ;
338
+ }
339
+
340
+ [ Fact ]
341
+ public async Task VerifyValidClientCertFailsWithoutAdditionalCertificatesAuthenticates ( )
342
+ {
343
+ using var host = await CreateHost (
344
+ new CertificateAuthenticationOptions
345
+ {
346
+ Events = successfulValidationEvents ,
347
+ ChainTrustValidationMode = X509ChainTrustMode . CustomRootTrust ,
348
+ CustomTrustStore = new X509Certificate2Collection ( ) { Certificates . SelfSignedPrimaryRoot , } ,
349
+ RevocationMode = X509RevocationMode . NoCheck
350
+ } , Certificates . SignedClient ) ;
351
+
352
+ using var server = host . GetTestServer ( ) ;
353
+ var response = await server . CreateClient ( ) . GetAsync ( "https://example.com/" ) ;
354
+ Assert . Equal ( HttpStatusCode . Forbidden , response . StatusCode ) ;
355
+ }
356
+
322
357
[ Fact ]
323
358
public async Task VerifyHeaderIsUsedIfCertIsNotPresent ( )
324
359
{
@@ -570,7 +605,7 @@ public async Task VerifyValidationResultCanBeCached(bool cache)
570
605
Assert . Equal ( Expected , name . First ( ) . Value ) ;
571
606
count = responseAsXml . Elements ( "claim" ) . Where ( claim => claim . Attribute ( "Type" ) . Value == "ValidationCount" ) ;
572
607
Assert . Single ( count ) ;
573
- var expected = cache ? "1" : "2" ;
608
+ var expected = cache ? "1" : "2" ;
574
609
Assert . Equal ( expected , count . First ( ) . Value ) ;
575
610
}
576
611
@@ -693,6 +728,7 @@ private static async Task<IHost> CreateHost(
693
728
options . RevocationFlag = configureOptions . RevocationFlag ;
694
729
options . RevocationMode = configureOptions . RevocationMode ;
695
730
options . ValidateValidityPeriod = configureOptions . ValidateValidityPeriod ;
731
+ options . AdditionalChainCertificates = configureOptions . AdditionalChainCertificates ;
696
732
} ) ;
697
733
}
698
734
else
0 commit comments