Fix issue with X509VerificationFlags.AllowUnknownCertificateAuthority behavior (#174)
* Fix issue with X509VerificationFlags.AllowUnknownCertificateAuthority behavior * Add CertificateValidationTests
This commit is contained in:
committed by
Brendan Burns
parent
f488d54ce7
commit
6eb5555145
37
tests/KubernetesClient.Tests/CertificateValidationTests.cs
Normal file
37
tests/KubernetesClient.Tests/CertificateValidationTests.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net.Security;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using Xunit;
|
||||
|
||||
namespace k8s.tests
|
||||
{
|
||||
public class CertificateValidationTests
|
||||
{
|
||||
[Fact]
|
||||
public void ValidCert()
|
||||
{
|
||||
var caCert = new X509Certificate2("assets/ca.crt");
|
||||
var testCert = new X509Certificate2("assets/ca.crt");
|
||||
var chain = new X509Chain();
|
||||
var errors = SslPolicyErrors.RemoteCertificateChainErrors;
|
||||
|
||||
var result = Kubernetes.CertificateValidationCallBack(this, caCert, testCert, chain, errors);
|
||||
|
||||
Assert.True(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InvalidCert()
|
||||
{
|
||||
var caCert = new X509Certificate2("assets/ca.crt");
|
||||
var testCert = new X509Certificate2("assets/ca2.crt");
|
||||
var chain = new X509Chain();
|
||||
var errors = SslPolicyErrors.RemoteCertificateChainErrors;
|
||||
|
||||
var result = Kubernetes.CertificateValidationCallBack(this, caCert, testCert, chain, errors);
|
||||
|
||||
Assert.False(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user