Skip to content

Commit b650d91

Browse files
logging full raw response, updated serialization config to ignore null values
1 parent b452a66 commit b650d91

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

hashicorp-vault-cagateway/APIProxy/CertResponse.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ public class CertResponse
1818
[JsonPropertyName("revocation_time_rfc3339")]
1919
public DateTime? RevocationTime { get; set; }
2020

21+
[JsonPropertyName("revocation_time")]
22+
public int RevocationTimestamp { get; set; }
23+
2124
[JsonPropertyName("issuer_id")]
2225
public string IssuerId { get; set; }
2326
}

hashicorp-vault-cagateway/Client/VaultHttp.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
using System.Collections.Generic;
1515
using System.Text.Json;
1616
using System.Text.Json.Serialization;
17+
using System.Threading;
1718
using System.Threading.Tasks;
1819

1920
namespace Keyfactor.Extensions.CAPlugin.HashicorpVault.Client
@@ -35,10 +36,9 @@ public VaultHttp(string host, string mountPoint, string authToken, string nameSp
3536

3637
_serializerOptions = new()
3738
{
38-
DefaultIgnoreCondition = JsonIgnoreCondition.Never,
39-
PropertyNameCaseInsensitive = true,
40-
RespectNullableAnnotations = true,
41-
PreferredObjectCreationHandling = JsonObjectCreationHandling.Replace
39+
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
40+
PropertyNameCaseInsensitive = true,
41+
PreferredObjectCreationHandling = JsonObjectCreationHandling.Populate
4242
};
4343

4444
var restClientOptions = new RestClientOptions($"{host.TrimEnd('/')}/v1") { ThrowOnAnyError = true };
@@ -69,15 +69,15 @@ public VaultHttp(string host, string mountPoint, string authToken, string nameSp
6969
public async Task<T> GetAsync<T>(string path, Dictionary<string, string> parameters = null)
7070
{
7171
logger.MethodEntry();
72-
logger.LogTrace($"preparing to send GET request to {path} with parameters {JsonSerializer.Serialize(parameters)}");
72+
logger.LogTrace($"preparing to send GET request to {_mountPoint}/{path} with parameters {JsonSerializer.Serialize(parameters)}");
7373

7474
try
7575
{
7676
var request = new RestRequest($"{_mountPoint}/{path}", Method.Get);
7777
if (parameters != null && parameters.Keys.Count > 0) { request.AddJsonBody(parameters); }
7878
var response = await _restClient.ExecuteGetAsync(request);
7979

80-
logger.LogTrace($"raw response: {response.Content}");
80+
logger.LogTrace($"raw response: {JsonSerializer.Serialize(response)}");
8181

8282
logger.LogTrace($"response status: {response.StatusCode}");
8383

hashicorp-vault-cagateway/HashicorpVaultCAConnector.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,11 +301,12 @@ public async Task Synchronize(BlockingCollection<AnyCAPluginCertificate> blockin
301301
{
302302
metaData = await _client.GetCertMetadata(certSerial);
303303
}
304-
catch (Exception)
304+
catch (Exception ex)
305305
{
306-
logger.LogTrace("an error occurred when attempting to retrieve the metadata, continuing..");
306+
logger.LogTrace($"an error occurred when attempting to retrieve the metadata, continuing.. {LogHandler.FlattenException(ex)}");
307307
}
308308

309+
309310
var newCert = new AnyCAPluginCertificate
310311
{
311312
CARequestID = trackingId,

hashicorp-vault-cagateway/hashicorp-vault-caplugin.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
<ItemGroup>
3636
<PackageReference Include="BouncyCastle.Cryptography" Version="2.6.2" />
3737
<PackageReference Include="Keyfactor.AnyGateway.IAnyCAPlugin" Version="3.1.0" />
38+
<PackageReference Include="Keyfactor.AnyGateway.SDK" Version="21.3.2">
39+
<PrivateAssets>all</PrivateAssets>
40+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
41+
</PackageReference>
3842
<PackageReference Include="Keyfactor.Logging" Version="1.3.0" />
3943
<PackageReference Include="Keyfactor.PKI" Version="8.1.1" />
4044
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.0" />

0 commit comments

Comments
 (0)