Merge pull request #39 from tg123/rename_param
rename client cert params to a better name
This commit is contained in:
@@ -73,9 +73,9 @@ namespace k8s
|
||||
}
|
||||
// othwerwise set handler for clinet cert based auth
|
||||
else if ((!string.IsNullOrWhiteSpace(config.ClientCertificateData) ||
|
||||
!string.IsNullOrWhiteSpace(config.ClientCertificate)) &&
|
||||
(!string.IsNullOrWhiteSpace(config.ClientCertificateKey) ||
|
||||
!string.IsNullOrWhiteSpace(config.ClientKey)))
|
||||
!string.IsNullOrWhiteSpace(config.ClientCertificateFilePath)) &&
|
||||
(!string.IsNullOrWhiteSpace(config.ClientCertificateKeyData) ||
|
||||
!string.IsNullOrWhiteSpace(config.ClientKeyFilePath)))
|
||||
{
|
||||
var cert = Utils.GeneratePfx(config);
|
||||
handler.ClientCertificates.Add(cert);
|
||||
|
||||
@@ -178,15 +178,15 @@ namespace k8s
|
||||
!string.IsNullOrWhiteSpace(userDetails.UserCredentials.ClientKeyData))
|
||||
{
|
||||
this.ClientCertificateData = userDetails.UserCredentials.ClientCertificateData;
|
||||
this.ClientCertificateKey = userDetails.UserCredentials.ClientKeyData;
|
||||
this.ClientCertificateKeyData = userDetails.UserCredentials.ClientKeyData;
|
||||
userCredentialsFound = true;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(userDetails.UserCredentials.ClientCertificate) &&
|
||||
!string.IsNullOrWhiteSpace(userDetails.UserCredentials.ClientKey))
|
||||
{
|
||||
this.ClientCertificate = userDetails.UserCredentials.ClientCertificate;
|
||||
this.ClientKey = userDetails.UserCredentials.ClientKey;
|
||||
this.ClientCertificateFilePath = userDetails.UserCredentials.ClientCertificate;
|
||||
this.ClientKeyFilePath = userDetails.UserCredentials.ClientKey;
|
||||
userCredentialsFound = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,17 +36,17 @@ namespace k8s
|
||||
/// <summary>
|
||||
/// Gets ClientCertificate Key
|
||||
/// </summary>
|
||||
public string ClientCertificateKey { get; set; }
|
||||
public string ClientCertificateKeyData { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets ClientCertificate filename
|
||||
/// </summary>
|
||||
public string ClientCertificate { get; set; }
|
||||
public string ClientCertificateFilePath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets ClientCertificate Key filename
|
||||
/// </summary>
|
||||
public string ClientKey { get; set; }
|
||||
public string ClientKeyFilePath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether to skip ssl server cert validation
|
||||
|
||||
12
src/Utils.cs
12
src/Utils.cs
@@ -60,13 +60,13 @@ namespace k8s
|
||||
byte[] keyData = null;
|
||||
byte[] certData = null;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(config.ClientCertificateKey))
|
||||
if (!string.IsNullOrWhiteSpace(config.ClientCertificateKeyData))
|
||||
{
|
||||
keyData = Convert.FromBase64String(config.ClientCertificateKey);
|
||||
keyData = Convert.FromBase64String(config.ClientCertificateKeyData);
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(config.ClientKey))
|
||||
if (!string.IsNullOrWhiteSpace(config.ClientKeyFilePath))
|
||||
{
|
||||
keyData = File.ReadAllBytes(config.ClientKey);
|
||||
keyData = File.ReadAllBytes(config.ClientKeyFilePath);
|
||||
}
|
||||
|
||||
if (keyData == null)
|
||||
@@ -78,9 +78,9 @@ namespace k8s
|
||||
{
|
||||
certData = Convert.FromBase64String(config.ClientCertificateData);
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(config.ClientCertificate))
|
||||
if (!string.IsNullOrWhiteSpace(config.ClientCertificateFilePath))
|
||||
{
|
||||
certData = File.ReadAllBytes(config.ClientCertificate);
|
||||
certData = File.ReadAllBytes(config.ClientCertificateFilePath);
|
||||
}
|
||||
|
||||
if (certData == null)
|
||||
|
||||
@@ -185,7 +185,7 @@ namespace k8s.Tests
|
||||
{
|
||||
Host = server.Uri.ToString(),
|
||||
ClientCertificateData = clientCertificateData,
|
||||
ClientCertificateKey = clientCertificateKeyData,
|
||||
ClientCertificateKeyData = clientCertificateKeyData,
|
||||
SslCaCert = serverCertificate,
|
||||
SkipTlsVerify = false
|
||||
});
|
||||
@@ -203,7 +203,7 @@ namespace k8s.Tests
|
||||
{
|
||||
Host = server.Uri.ToString(),
|
||||
ClientCertificateData = clientCertificateData,
|
||||
ClientCertificateKey = clientCertificateKeyData,
|
||||
ClientCertificateKeyData = clientCertificateKeyData,
|
||||
SkipTlsVerify = true
|
||||
});
|
||||
|
||||
@@ -219,8 +219,8 @@ namespace k8s.Tests
|
||||
var client = new Kubernetes(new KubernetesClientConfiguration
|
||||
{
|
||||
Host = server.Uri.ToString(),
|
||||
ClientCertificate = "assets/client.crt", // TODO amazoning why client.crt != client-data.txt
|
||||
ClientKey = "assets/client.key", // TODO bad naming param
|
||||
ClientCertificateFilePath = "assets/client.crt", // TODO amazoning why client.crt != client-data.txt
|
||||
ClientKeyFilePath = "assets/client.key",
|
||||
SkipTlsVerify = true
|
||||
});
|
||||
|
||||
|
||||
@@ -120,8 +120,8 @@ namespace k8s.Tests
|
||||
var fi = new FileInfo(kubeConfigFileName);
|
||||
var cfg = new KubernetesClientConfiguration(fi, context);
|
||||
Assert.Equal(context, cfg.CurrentContext);
|
||||
Assert.Equal(cfg.ClientCertificate, clientCert);
|
||||
Assert.Equal(cfg.ClientKey, clientCertKey);
|
||||
Assert.Equal(cfg.ClientCertificateFilePath, clientCert);
|
||||
Assert.Equal(cfg.ClientKeyFilePath, clientCertKey);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -137,7 +137,7 @@ namespace k8s.Tests
|
||||
Assert.Equal(context, cfg.CurrentContext);
|
||||
Assert.NotNull(cfg.SslCaCert);
|
||||
Assert.Equal(readLine("assets/client-certificate-data.txt"), cfg.ClientCertificateData);
|
||||
Assert.Equal(readLine("assets/client-key-data.txt"), cfg.ClientCertificateKey);
|
||||
Assert.Equal(readLine("assets/client-key-data.txt"), cfg.ClientCertificateKeyData);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user