File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 151151 }
152152 break ;
153153 case "f" :
154- certificate = new X509Certificate2 ( "../../../Andreas_Orzelski_Chain.pfx" , "i40" ) ;
155-
154+ var name = "Andreas_Orzelski_Chain.pfx" ;
155+ var pw = "i40" ;
156+ // var name = "I40_IDTA_Sandeep_Rudra.pfx";
157+ // var name = "idta-client.pfx";
158+ certificate = new X509Certificate2 ( $ "../../../{ name } ", pw ) ;
159+
156160 // Zertifikatskette vorbereiten
157161 var chain = new X509Certificate2Collection ( ) ;
158- chain . Import ( "../../../Andreas_Orzelski_Chain.pfx " , "i40" ) ;
162+ chain . Import ( $ "../../../{ name } ", pw ) ;
159163 x5c = chain . Cast < X509Certificate2 > ( ) . Reverse ( ) . Select ( c => Convert . ToBase64String ( c . RawData ) ) . ToArray ( ) ;
164+
165+ var ch2 = new X509Chain
166+ {
167+ ChainPolicy = {
168+ RevocationMode = X509RevocationMode . NoCheck ,
169+ VerificationFlags = X509VerificationFlags . NoFlag ,
170+ TrustMode = X509ChainTrustMode . CustomRootTrust
171+ }
172+ } ;
173+
174+ var root = new X509Certificate2 ( Convert . FromBase64String ( x5c . Last ( ) ) ) ;
175+ ch2 . ChainPolicy . CustomTrustStore . Add ( root ) ;
176+
177+ for ( var i = 1 ; i < x5c . Length - 1 ; i ++ )
178+ {
179+ var cert = new X509Certificate2 ( Convert . FromBase64String ( x5c [ i ] ) ) ;
180+ ch2 . ChainPolicy . ExtraStore . Add ( cert ) ;
181+ }
182+
183+ var isValid = ch2 . Build ( certificate ) ;
160184 break ;
161185 case "e" :
162186 Console . WriteLine ( "Entra ID?" ) ;
You can’t perform that action at this time.
0 commit comments