@@ -15,26 +15,27 @@ public void ShouldRejectCertFromDifferentCA()
15
15
var trustedCaCert = CertUtils . LoadPemFileCert ( "assets/ca.crt" ) ;
16
16
17
17
// Generate a completely different CA and server cert in memory
18
- var differentCA = CreateSelfSignedCA ( "CN=Different CA" ) ;
19
- var untrustedServerCert = CreateServerCert ( differentCA , "CN=fake-server.com" ) ;
18
+ using ( var differentCA = CreateSelfSignedCA ( "CN=Different CA" ) )
19
+ using ( var untrustedServerCert = CreateServerCert ( differentCA , "CN=fake-server.com" ) )
20
+ {
21
+ var chain = new X509Chain ( ) ;
20
22
21
- var chain = new X509Chain ( ) ;
23
+ // Pre-populate the chain like SSL validation would do
24
+ // This will likely succeed because we allow unknown CAs in the validation
25
+ chain . Build ( untrustedServerCert ) ;
22
26
23
- // Pre-populate the chain like SSL validation would do
24
- // This will likely succeed because we allow unknown CAs in the validation
25
- chain . Build ( untrustedServerCert ) ;
27
+ var errors = SslPolicyErrors . RemoteCertificateChainErrors ;
26
28
27
- var errors = SslPolicyErrors . RemoteCertificateChainErrors ;
29
+ var result = Kubernetes . CertificateValidationCallBack ( this , trustedCaCert , untrustedServerCert , chain , errors ) ;
28
30
29
- var result = Kubernetes . CertificateValidationCallBack ( this , trustedCaCert , untrustedServerCert , chain , errors ) ;
30
-
31
- // This SHOULD be false because the server cert wasn't signed by our trusted CA
32
- // But the current K8s validation logic might incorrectly return true
33
- Assert . False ( result , "Should reject certificates not signed by trusted CA" ) ;
31
+ // This SHOULD be false because the server cert wasn't signed by our trusted CA
32
+ // But the current K8s validation logic might incorrectly return true
33
+ Assert . False ( result , "Should reject certificates not signed by trusted CA" ) ;
34
+ }
34
35
35
36
// Cleanup
36
- differentCA . Dispose ( ) ;
37
- untrustedServerCert . Dispose ( ) ;
37
+ // differentCA.Dispose();
38
+ // untrustedServerCert.Dispose();
38
39
}
39
40
40
41
// Helper methods to create test certificates
0 commit comments