From 7fb9e790916ac4480da75deb27cd90acb4fdccd1 Mon Sep 17 00:00:00 2001 From: HorizonSecuritySRL <38698068+HorizonSecuritySRL@users.noreply.github.com> Date: Tue, 24 Apr 2018 17:55:37 +0200 Subject: [PATCH 01/18] Add CertPath --- src/Vault/VaultOptions.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Vault/VaultOptions.cs b/src/Vault/VaultOptions.cs index a710217..74ce690 100644 --- a/src/Vault/VaultOptions.cs +++ b/src/Vault/VaultOptions.cs @@ -8,6 +8,7 @@ public class VaultOptions : IOptions public string Address { get; set; } = "https://localhost:8200"; public string Token { get; set; } + public string CertPath { get; set; } VaultOptions IOptions.Value => this; } From 3c01b553a014c7b2d40f290062056abcc2aecc39 Mon Sep 17 00:00:00 2001 From: HorizonSecuritySRL <38698068+HorizonSecuritySRL@users.noreply.github.com> Date: Tue, 24 Apr 2018 17:59:03 +0200 Subject: [PATCH 02/18] Initialization HttpClient --- src/Vault/VaultHttpClient.cs | 37 +++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/Vault/VaultHttpClient.cs b/src/Vault/VaultHttpClient.cs index 8fb7c98..7d46cec 100644 --- a/src/Vault/VaultHttpClient.cs +++ b/src/Vault/VaultHttpClient.cs @@ -1,7 +1,10 @@ using System; +using System.Linq; using System.Net; using System.Net.Http; using System.Net.Http.Headers; +using System.Net.Security; +using System.Security.Cryptography.X509Certificates; using System.Text; using System.Threading; using System.Threading.Tasks; @@ -11,7 +14,39 @@ namespace Vault { public class VaultHttpClient : IVaultHttpClient { - private static readonly HttpClient HttpClient = new HttpClient(); + public static HttpClient HttpClientinitialization() + { + HttpClient httpClient = null; + + if (!string.IsNullOrEmpty(Vault.VaultOptions.Default.CertPath)) + { + var handler = new HttpClientHandler(); + + handler.ServerCertificateCustomValidationCallback = (request, cert, chain, errors) => + { + const SslPolicyErrors unforgivableErrors = + SslPolicyErrors.RemoteCertificateNotAvailable | + SslPolicyErrors.RemoteCertificateNameMismatch; + + if ((errors & unforgivableErrors) != 0) + { + return false; + } + + X509Certificate2 remoteRoot = chain.ChainElements[chain.ChainElements.Count - 1].Certificate; + return new X509Certificate2(Vault.VaultOptions.Default.CertPath).RawData.SequenceEqual(remoteRoot.RawData); + }; + + httpClient = new HttpClient(handler); + } + else + { + httpClient = new HttpClient(); + } + return httpClient; + } + + private static readonly HttpClient HttpClient = HttpClientinitialization(); public VaultHttpClient() { From bef516d65c63e071153bc56a5aaad1648f9a9393 Mon Sep 17 00:00:00 2001 From: HorizonSecuritySRL <38698068+HorizonSecuritySRL@users.noreply.github.com> Date: Tue, 24 Apr 2018 18:18:11 +0200 Subject: [PATCH 03/18] Update README.md --- README.md | 106 +++++++++--------------------------------------------- 1 file changed, 16 insertions(+), 90 deletions(-) diff --git a/README.md b/README.md index 3b91aa4..857dce8 100644 --- a/README.md +++ b/README.md @@ -1,98 +1,24 @@ -# Vault.NET [![Build status](https://ci.appveyor.com/api/projects/status/784hg5j70vcnumeb/branch/master?svg=true)](https://ci.appveyor.com/project/chatham/vault-net/branch/master) +# Vault.NET Local Certificate -* Vault API: v0.9.1 -* .NET Standard 1.3 (.NET: >= 4.6, .NET Core: >= 1.0.0) -* .NET 4.5 -* Nuget: Vault [![NuGet](https://img.shields.io/nuget/v/Vault.svg)](https://www.nuget.org/packages/Vault/) +I have defined a new property "CertPah" that is populated before the definition of the httpcliet. -Vault.NET is an .NET API client for the interacting with [Vault](https://www.vaultproject.io/). This is a port of the go api client and provides generic methods for interacting with the paths in Vault. +In case it is empty, the behavior remains unchanged. -## Example +If it is different from empty, then the certificate is taken locally and contributes to Vault API calls. -```csharp -using Vault; - -var vaultClient = new VaultClient(); -vaultClient.Token = "XXXXXX"; -``` - -### Generic Secret - -```csharp -var data = new Dictionary +```csharp +public static async Task> VaultAsync(string secretPath) { - {"zip", "zap"} -}; -await vaultClient.Secret.Write("secret/foo", data); - -var secret = await vaultClient.Secret.Read>("secret/foo"); -Console.WriteLine(secret.Data["zip"]); - -// zap -``` - -### PKI - -```csharp -using Vault.Models.Secret.Pki; - -var testRole = new RolesRequest -{ - AllowAnyDomain = true, - EnforceHostnames = false, - MaxTtl = "1h" -}; -await vaultClient.Secret.Write("pki/roles/test", testRole); - -var certRequest = new IssueRequest -{ - CommonName = "Test Cert" -}; -var cert = await vaultClient.Secret.Write("pki/issue/test", certRequest); -Console.WriteLine(secret.Data.Certificate); - -// -----BEGIN CERTIFICATE----- -// MII... -``` - -### Username/Password Authentication - -```csharp -using Vault.Models.Auth.UserPass; - -await vaultClient.Sys.EnableAuth("userpass", "userpass", "Userpass Mount"); - -var usersRequest = new UsersRequest -{ - Password = "password", - Policies = new List { "default" }, - Ttl = "1h", - MaxTtl = "2h" -}; -await vaultClient.Auth.Write("userpass/users/username", usersRequest); - -var loginRequest = new LoginRequest -{ - Password = "password" -}; -var loginResponse = await vaultClient.Auth.Write("userpass/login/username", loginRequest); - -// Set client token to authenticated token -vaultClient.Token = loginResponse.Auth.ClientToken; - -// Proceed with authenticated requests -``` - -## Models - -Many request/response objects are provided in this package to support different backends. This is in no way an exhaustive list of all the objects. Since the models are the things that are going to most likely change between versions of vault, it may make sense to make your own to service your needs. These may get split into a seperate Nuget package in the future. - -## Testing - -Since most of the operation of this library are just building requests and passing them to the vault API and the vault team provides an easy to use local development server, each test runs against its own vault server. This means that tests require the vault binary available to spin up the vault server instance. The test suite will first look for the environment variable `VAULT_BIN` and if not found will fall back to use the `vault` binary in the `$PATH`. + VaultOptions.Default.CertPath = new DirectoryInfo( + Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, @"..\..\" + "AppData\\cert.crt")) + ).ToString(); -Downloads for vault can be found [here](https://www.vaultproject.io/downloads.html). + var vaultClient = new VaultClient(); + vaultClient.Address = new System.Uri("https://vault.personal.domain.com:8200"); + vaultClient.Token = "token"; -## Versioning + var secret = await vaultClient.Secret.Read>(secretPath); -This library will follow the version of vault that it was developed against. Since most core operations of vault maintain backwards compatibility, this library can be used against many older and newer versions of vault. If features are added or bugs are fixed, a new point release will be created (ex. 0.6.4 -> 0.6.4.1). If there is some functionality that breaks on a newer version of vault, please submit a pull request. + return secret.Data; +} +``` From 06cb60714048a0113b9c1126459e33ab20c6b172 Mon Sep 17 00:00:00 2001 From: HorizonSecuritySRL <38698068+HorizonSecuritySRL@users.noreply.github.com> Date: Thu, 26 Apr 2018 10:10:46 +0200 Subject: [PATCH 04/18] Update Vault.csproj --- src/Vault/Vault.csproj | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Vault/Vault.csproj b/src/Vault/Vault.csproj index fbd91ef..5e07255 100644 --- a/src/Vault/Vault.csproj +++ b/src/Vault/Vault.csproj @@ -29,5 +29,11 @@ + + + + 5.2.4 + + From 16641a693be9be512d382fabd00b6c3e3044d52a Mon Sep 17 00:00:00 2001 From: HorizonSecuritySRL <38698068+HorizonSecuritySRL@users.noreply.github.com> Date: Thu, 26 Apr 2018 10:12:00 +0200 Subject: [PATCH 05/18] Update Vault.Tests.csproj --- test/Vault.Tests/Vault.Tests.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/test/Vault.Tests/Vault.Tests.csproj b/test/Vault.Tests/Vault.Tests.csproj index b2ce0af..c75280e 100644 --- a/test/Vault.Tests/Vault.Tests.csproj +++ b/test/Vault.Tests/Vault.Tests.csproj @@ -7,6 +7,7 @@ + From 53ceb495984049795f101bedb54b42951212816c Mon Sep 17 00:00:00 2001 From: HorizonSecuritySRL <38698068+HorizonSecuritySRL@users.noreply.github.com> Date: Thu, 26 Apr 2018 10:23:09 +0200 Subject: [PATCH 06/18] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 857dce8..a3570ed 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ # Vault.NET Local Certificate +Required NuGe Packages: + +- Microsoft.AspNet.WebApi.Client + I have defined a new property "CertPah" that is populated before the definition of the httpcliet. In case it is empty, the behavior remains unchanged. From 2b9f774a468f98c749f279a05f74b38bbf9ffb04 Mon Sep 17 00:00:00 2001 From: HorizonSecuritySRL <38698068+HorizonSecuritySRL@users.noreply.github.com> Date: Thu, 26 Apr 2018 10:24:45 +0200 Subject: [PATCH 07/18] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a3570ed..517d00c 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,9 @@ # Vault.NET Local Certificate -Required NuGe Packages: +Required Packages/Assembly: - Microsoft.AspNet.WebApi.Client +- System.Net.Http.Formatting.dll I have defined a new property "CertPah" that is populated before the definition of the httpcliet. From 04a536ff1713eb8b8048dacd0875bdf2fdc5328c Mon Sep 17 00:00:00 2001 From: HorizonSecuritySRL <38698068+HorizonSecuritySRL@users.noreply.github.com> Date: Thu, 26 Apr 2018 11:02:55 +0200 Subject: [PATCH 08/18] Update Vault.csproj --- src/Vault/Vault.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Vault/Vault.csproj b/src/Vault/Vault.csproj index 5e07255..6145bbe 100644 --- a/src/Vault/Vault.csproj +++ b/src/Vault/Vault.csproj @@ -28,6 +28,7 @@ + From 9a990949594f637ea8a3efe1556551fc536ffd17 Mon Sep 17 00:00:00 2001 From: HorizonSecuritySRL <38698068+HorizonSecuritySRL@users.noreply.github.com> Date: Thu, 26 Apr 2018 13:55:29 +0200 Subject: [PATCH 09/18] Update README.md --- README.md | 96 ++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 77 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 517d00c..2f81d16 100644 --- a/README.md +++ b/README.md @@ -1,29 +1,87 @@ -# Vault.NET Local Certificate +# Vault.NET [![Build status](https://ci.appveyor.com/api/projects/status/784hg5j70vcnumeb/branch/master?svg=true)](https://ci.appveyor.com/project/chatham/vault-net/branch/master) -Required Packages/Assembly: +* Vault API: v0.9.1 +* .NET Standard 1.3 (.NET: >= 4.6, .NET Core: >= 1.0.0) +* .NET 4.5 +* Nuget: Vault [![NuGet](https://img.shields.io/nuget/v/Vault.svg)](https://www.nuget.org/packages/Vault/) -- Microsoft.AspNet.WebApi.Client -- System.Net.Http.Formatting.dll +Vault.NET is an .NET API client for the interacting with [Vault](https://www.vaultproject.io/). This is a port of the go api client and provides generic methods for interacting with the paths in Vault. -I have defined a new property "CertPah" that is populated before the definition of the httpcliet. +## Example -In case it is empty, the behavior remains unchanged. +```csharp +using Vault; +var vaultClient = new VaultClient(); +vaultClient.Token = "XXXXXX"; +``` -If it is different from empty, then the certificate is taken locally and contributes to Vault API calls. +### Generic Secret -```csharp -public static async Task> VaultAsync(string secretPath) +```csharp +var data = new Dictionary { - VaultOptions.Default.CertPath = new DirectoryInfo( - Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, @"..\..\" + "AppData\\cert.crt")) - ).ToString(); + {"zip", "zap"} +}; +await vaultClient.Secret.Write("secret/foo", data); +var secret = await vaultClient.Secret.Read>("secret/foo"); +Console.WriteLine(secret.Data["zip"]); +// zap +``` - var vaultClient = new VaultClient(); - vaultClient.Address = new System.Uri("https://vault.personal.domain.com:8200"); - vaultClient.Token = "token"; +### PKI - var secret = await vaultClient.Secret.Read>(secretPath); +```csharp +using Vault.Models.Secret.Pki; +var testRole = new RolesRequest +{ + AllowAnyDomain = true, + EnforceHostnames = false, + MaxTtl = "1h" +}; +await vaultClient.Secret.Write("pki/roles/test", testRole); +var certRequest = new IssueRequest +{ + CommonName = "Test Cert" +}; +var cert = await vaultClient.Secret.Write("pki/issue/test", certRequest); +Console.WriteLine(secret.Data.Certificate); +// -----BEGIN CERTIFICATE----- +// MII... +``` + +### Username/Password Authentication + +```csharp +using Vault.Models.Auth.UserPass; +await vaultClient.Sys.EnableAuth("userpass", "userpass", "Userpass Mount"); +var usersRequest = new UsersRequest +{ + Password = "password", + Policies = new List { "default" }, + Ttl = "1h", + MaxTtl = "2h" +}; +await vaultClient.Auth.Write("userpass/users/username", usersRequest); +var loginRequest = new LoginRequest +{ + Password = "password" +}; +var loginResponse = await vaultClient.Auth.Write("userpass/login/username", loginRequest); +// Set client token to authenticated token +vaultClient.Token = loginResponse.Auth.ClientToken; +// Proceed with authenticated requests +``` + +## Models + +Many request/response objects are provided in this package to support different backends. This is in no way an exhaustive list of all the objects. Since the models are the things that are going to most likely change between versions of vault, it may make sense to make your own to service your needs. These may get split into a seperate Nuget package in the future. + +## Testing + +Since most of the operation of this library are just building requests and passing them to the vault API and the vault team provides an easy to use local development server, each test runs against its own vault server. This means that tests require the vault binary available to spin up the vault server instance. The test suite will first look for the environment variable `VAULT_BIN` and if not found will fall back to use the `vault` binary in the `$PATH`. + +Downloads for vault can be found [here](https://www.vaultproject.io/downloads.html). + +## Versioning - return secret.Data; -} -``` +This library will follow the version of vault that it was developed against. Since most core operations of vault maintain backwards compatibility, this library can be used against many older and newer versions of vault. If features are added or bugs are fixed, a new point release will be created (ex. 0.6.4 -> 0.6.4.1). If there is some functionality that breaks on a newer version of vault, please submit a pull request. From 733c2eb8497c6bdc237602ae4460280227ad54e2 Mon Sep 17 00:00:00 2001 From: HorizonSecuritySRL <38698068+HorizonSecuritySRL@users.noreply.github.com> Date: Thu, 26 Apr 2018 15:13:09 +0200 Subject: [PATCH 10/18] Update Vault.csproj --- src/Vault/Vault.csproj | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/Vault/Vault.csproj b/src/Vault/Vault.csproj index 6145bbe..fbd91ef 100644 --- a/src/Vault/Vault.csproj +++ b/src/Vault/Vault.csproj @@ -28,13 +28,6 @@ - - - - - 5.2.4 - - From 187cbf7e68c26f00223ebcd19f38e8eacec8562d Mon Sep 17 00:00:00 2001 From: HorizonSecuritySRL <38698068+HorizonSecuritySRL@users.noreply.github.com> Date: Thu, 26 Apr 2018 15:13:38 +0200 Subject: [PATCH 11/18] Update Vault.Tests.csproj --- test/Vault.Tests/Vault.Tests.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/test/Vault.Tests/Vault.Tests.csproj b/test/Vault.Tests/Vault.Tests.csproj index c75280e..b2ce0af 100644 --- a/test/Vault.Tests/Vault.Tests.csproj +++ b/test/Vault.Tests/Vault.Tests.csproj @@ -7,7 +7,6 @@ - From 90bd0bd06d2267c94f946a5911b1098206bfc903 Mon Sep 17 00:00:00 2001 From: HorizonSecuritySRL <38698068+HorizonSecuritySRL@users.noreply.github.com> Date: Wed, 9 May 2018 15:42:18 +0200 Subject: [PATCH 12/18] CertificateCustomValidation Validation custom certificate for Vault Callback Request --- src/Vault/VaultHttpClient.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Vault/VaultHttpClient.cs b/src/Vault/VaultHttpClient.cs index 7d46cec..1fb3dff 100644 --- a/src/Vault/VaultHttpClient.cs +++ b/src/Vault/VaultHttpClient.cs @@ -17,11 +17,20 @@ public class VaultHttpClient : IVaultHttpClient public static HttpClient HttpClientinitialization() { HttpClient httpClient = null; + var handler = new HttpClientHandler(); + #if NET45 + if (!string.IsNullOrEmpty(Vault.VaultOptions.Default.CertPath)) + { + X509Certificate cert = new X509Certificate(); + cert.Import(Vault.VaultOptions.Default.CertPath); + httpClient = new HttpClient(handler); + } + else + httpClient = new HttpClient(); + #else if (!string.IsNullOrEmpty(Vault.VaultOptions.Default.CertPath)) { - var handler = new HttpClientHandler(); - handler.ServerCertificateCustomValidationCallback = (request, cert, chain, errors) => { const SslPolicyErrors unforgivableErrors = @@ -36,13 +45,13 @@ public static HttpClient HttpClientinitialization() X509Certificate2 remoteRoot = chain.ChainElements[chain.ChainElements.Count - 1].Certificate; return new X509Certificate2(Vault.VaultOptions.Default.CertPath).RawData.SequenceEqual(remoteRoot.RawData); }; - httpClient = new HttpClient(handler); } else { httpClient = new HttpClient(); } + #endif return httpClient; } From 66fb741a9ffcf332b959ec964ed75334e36a6b74 Mon Sep 17 00:00:00 2001 From: HorizonSecuritySRL <38698068+HorizonSecuritySRL@users.noreply.github.com> Date: Mon, 14 May 2018 14:26:00 +0200 Subject: [PATCH 13/18] Add Reference Add System.Net.Http.WebRequest for TargetFramework net45 --- src/Vault/Vault.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Vault/Vault.csproj b/src/Vault/Vault.csproj index fbd91ef..e083b6b 100644 --- a/src/Vault/Vault.csproj +++ b/src/Vault/Vault.csproj @@ -28,6 +28,7 @@ + From 13fbc70823bf7278b6b349aab0f223d010db713b Mon Sep 17 00:00:00 2001 From: HorizonSecuritySRL <38698068+HorizonSecuritySRL@users.noreply.github.com> Date: Mon, 14 May 2018 14:29:40 +0200 Subject: [PATCH 14/18] Update VaultHttpClient.cs Add Custom Certificate for NET45 with WebRequestHandler --- src/Vault/VaultHttpClient.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Vault/VaultHttpClient.cs b/src/Vault/VaultHttpClient.cs index 1fb3dff..ae0d2e5 100644 --- a/src/Vault/VaultHttpClient.cs +++ b/src/Vault/VaultHttpClient.cs @@ -17,20 +17,21 @@ public class VaultHttpClient : IVaultHttpClient public static HttpClient HttpClientinitialization() { HttpClient httpClient = null; - var handler = new HttpClientHandler(); - + #if NET45 if (!string.IsNullOrEmpty(Vault.VaultOptions.Default.CertPath)) { - X509Certificate cert = new X509Certificate(); - cert.Import(Vault.VaultOptions.Default.CertPath); - httpClient = new HttpClient(handler); + WebRequestHandler requestHandler = new WebRequestHandler(); + requestHandler.ClientCertificateOptions = ClientCertificateOption.Manual; + requestHandler.ClientCertificates.Add(new X509Certificate2(Vault.VaultOptions.Default.CertPath)); + httpClient = new HttpClient(requestHandler); } else httpClient = new HttpClient(); #else if (!string.IsNullOrEmpty(Vault.VaultOptions.Default.CertPath)) { + var handler = new HttpClientHandler(); handler.ServerCertificateCustomValidationCallback = (request, cert, chain, errors) => { const SslPolicyErrors unforgivableErrors = From c7910a039c8ec20acd9e08c901d195b81ad0e50a Mon Sep 17 00:00:00 2001 From: HorizonSecuritySRL <38698068+HorizonSecuritySRL@users.noreply.github.com> Date: Mon, 14 May 2018 14:30:19 +0200 Subject: [PATCH 15/18] Update VaultHttpClient.cs --- src/Vault/VaultHttpClient.cs | 42 ++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/Vault/VaultHttpClient.cs b/src/Vault/VaultHttpClient.cs index ae0d2e5..aef01ca 100644 --- a/src/Vault/VaultHttpClient.cs +++ b/src/Vault/VaultHttpClient.cs @@ -29,29 +29,29 @@ public static HttpClient HttpClientinitialization() else httpClient = new HttpClient(); #else - if (!string.IsNullOrEmpty(Vault.VaultOptions.Default.CertPath)) - { - var handler = new HttpClientHandler(); - handler.ServerCertificateCustomValidationCallback = (request, cert, chain, errors) => + if (!string.IsNullOrEmpty(Vault.VaultOptions.Default.CertPath)) { - const SslPolicyErrors unforgivableErrors = - SslPolicyErrors.RemoteCertificateNotAvailable | - SslPolicyErrors.RemoteCertificateNameMismatch; - - if ((errors & unforgivableErrors) != 0) + var handler = new HttpClientHandler(); + handler.ServerCertificateCustomValidationCallback = (request, cert, chain, errors) => { - return false; - } - - X509Certificate2 remoteRoot = chain.ChainElements[chain.ChainElements.Count - 1].Certificate; - return new X509Certificate2(Vault.VaultOptions.Default.CertPath).RawData.SequenceEqual(remoteRoot.RawData); - }; - httpClient = new HttpClient(handler); - } - else - { - httpClient = new HttpClient(); - } + const SslPolicyErrors unforgivableErrors = + SslPolicyErrors.RemoteCertificateNotAvailable | + SslPolicyErrors.RemoteCertificateNameMismatch; + + if ((errors & unforgivableErrors) != 0) + { + return false; + } + + X509Certificate2 remoteRoot = chain.ChainElements[chain.ChainElements.Count - 1].Certificate; + return new X509Certificate2(Vault.VaultOptions.Default.CertPath).RawData.SequenceEqual(remoteRoot.RawData); + }; + httpClient = new HttpClient(handler); + } + else + { + httpClient = new HttpClient(); + } #endif return httpClient; } From 2f8e777ffe114ad1741d607678360d83db235e49 Mon Sep 17 00:00:00 2001 From: HorizonSecuritySRL <38698068+HorizonSecuritySRL@users.noreply.github.com> Date: Mon, 14 May 2018 14:35:02 +0200 Subject: [PATCH 16/18] Update VaultHttpClient.cs --- src/Vault/VaultHttpClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Vault/VaultHttpClient.cs b/src/Vault/VaultHttpClient.cs index aef01ca..1c65389 100644 --- a/src/Vault/VaultHttpClient.cs +++ b/src/Vault/VaultHttpClient.cs @@ -16,7 +16,7 @@ public class VaultHttpClient : IVaultHttpClient { public static HttpClient HttpClientinitialization() { - HttpClient httpClient = null; + HttpClient httpClient = new HttpClient(); #if NET45 if (!string.IsNullOrEmpty(Vault.VaultOptions.Default.CertPath)) From 60a9bbc69896851f95f1737a2fa345b919c84dfe Mon Sep 17 00:00:00 2001 From: HorizonSecuritySRL <38698068+HorizonSecuritySRL@users.noreply.github.com> Date: Mon, 14 May 2018 14:38:26 +0200 Subject: [PATCH 17/18] Update VaultHttpClient.cs Set the visibility method --- src/Vault/VaultHttpClient.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Vault/VaultHttpClient.cs b/src/Vault/VaultHttpClient.cs index 1c65389..864d4e9 100644 --- a/src/Vault/VaultHttpClient.cs +++ b/src/Vault/VaultHttpClient.cs @@ -14,7 +14,7 @@ namespace Vault { public class VaultHttpClient : IVaultHttpClient { - public static HttpClient HttpClientinitialization() + private static HttpClient HttpClientInitialization() { HttpClient httpClient = new HttpClient(); @@ -56,7 +56,7 @@ public static HttpClient HttpClientinitialization() return httpClient; } - private static readonly HttpClient HttpClient = HttpClientinitialization(); + private static readonly HttpClient HttpClient = HttpClientInitialization(); public VaultHttpClient() { From 29f65e6272559384042665ea4b2b060721260438 Mon Sep 17 00:00:00 2001 From: HorizonSecuritySRL <38698068+HorizonSecuritySRL@users.noreply.github.com> Date: Mon, 14 May 2018 14:45:34 +0200 Subject: [PATCH 18/18] Update VaultHttpClient.cs --- src/Vault/VaultHttpClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Vault/VaultHttpClient.cs b/src/Vault/VaultHttpClient.cs index 864d4e9..665740c 100644 --- a/src/Vault/VaultHttpClient.cs +++ b/src/Vault/VaultHttpClient.cs @@ -16,7 +16,7 @@ public class VaultHttpClient : IVaultHttpClient { private static HttpClient HttpClientInitialization() { - HttpClient httpClient = new HttpClient(); + HttpClient httpClient = null; #if NET45 if (!string.IsNullOrEmpty(Vault.VaultOptions.Default.CertPath))