File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed 
src/ITfoxtec.Identity.Saml2/Configuration Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change 33using  System . Collections . Generic ; 
44using  System . Security . Cryptography . X509Certificates ; 
55using  System . ServiceModel . Security ; 
6+ using  System . IdentityModel . Selectors ; 
67
78namespace  ITfoxtec . Identity . Saml2 
89{ 
@@ -25,6 +26,7 @@ public class Saml2Configuration
2526        public  List < X509Certificate2 >  SignatureValidationCertificates  {  get ;  protected  set ;  }  =  new  List < X509Certificate2 > ( ) ; 
2627        public  X509CertificateValidationMode  CertificateValidationMode  {  get ;  set ;  }  =  X509CertificateValidationMode . ChainTrust ; 
2728        public  X509RevocationMode  RevocationMode  {  get ;  set ;  }  =  X509RevocationMode . Online ; 
29+         public  X509CertificateValidator  CustomCertificateValidator  {  get ;  set ;  } 
2830
2931        public  bool  SaveBootstrapContext  {  get ;  set ;  }  =  false ; 
3032
Original file line number Diff line number Diff line change 1- using  System . Security . Cryptography . X509Certificates ; 
2- using  ITfoxtec . Identity . Saml2 . Util ; 
1+ using  System . ServiceModel . Security ; 
32#if NETFULL 
43using  ITfoxtec . Identity . Saml2 . Tokens ; 
54using  System ; 
87using  System . IdentityModel . Tokens ; 
98#else
109using  System . Linq ; 
10+ using  ITfoxtec . Identity . Saml2 . Util ; 
1111using  Microsoft . IdentityModel . Tokens ; 
1212using  System . Security . Claims ; 
1313using  System . IdentityModel . Selectors ; 
@@ -54,9 +54,25 @@ public static Saml2IdentityConfiguration GetIdentityConfiguration(Saml2Configura
5454                RevocationMode  =  config . RevocationMode , 
5555            } ; 
5656#endif
57+ 
58+             SetCustomCertificateValidator ( configuration ,  config ) ; 
59+ 
5760            return  configuration ; 
5861        } 
5962
63+         private  static void  SetCustomCertificateValidator ( Saml2IdentityConfiguration  configuration ,  Saml2Configuration  config ) 
64+         { 
65+             if  ( config . CertificateValidationMode  ==  X509CertificateValidationMode . Custom ) 
66+             { 
67+                 if  ( config . CustomCertificateValidator  is  null ) 
68+                 { 
69+                     throw  new  Saml2ConfigurationException ( "A CustomCertificateValidator is required when setting CertificateValidationMode = X509CertificateValidationMode.Custom" ) ; 
70+                 } 
71+ 
72+                 configuration . CertificateValidator  =  config . CustomCertificateValidator ; 
73+             } 
74+         } 
75+ 
6076#if NETFULL 
6177        private  static AudienceRestriction  GetAudienceRestriction ( bool  audienceRestricted ,  IEnumerable < string >  allowedAudienceUris ) 
6278        { 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments