Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed new certificate issue error #797

Merged
merged 1 commit into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions KeyVault.Acmebot/Functions/SharedActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -386,14 +386,9 @@ public async Task<OrderDetails> FinalizeOrder([ActivityTrigger] (CertificatePoli
try
{
var certificatePolicy = certificatePolicyItem.ToCertificatePolicy();
var metadata = certificatePolicyItem.ToCertificateMetadata(_options.Endpoint);

var certificateOperation = await _certificateClient.StartCreateCertificateAsync(certificatePolicyItem.CertificateName, certificatePolicy, tags: new Dictionary<string, string>
{
{ "Issuer", "Acmebot" },
{ "Endpoint", _options.Endpoint.Host },
{ "DnsProvider", certificatePolicyItem.DnsProviderName },
{ "DnsAlias", certificatePolicyItem.DnsAlias }
});
var certificateOperation = await _certificateClient.StartCreateCertificateAsync(certificatePolicyItem.CertificateName, certificatePolicy, tags: metadata);

csr = certificateOperation.Properties.Csr;
}
Expand Down
18 changes: 17 additions & 1 deletion KeyVault.Acmebot/Internal/CertificateExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,23 @@ public static CertificatePolicyItem ToCertificatePolicyItem(this KeyVaultCertifi
};
}

public static IDictionary<string, string> ToCertificateMetadata(this CertificatePolicyItem certificatePolicyItem, Uri endpoint)
{
var metadata = new Dictionary<string, string>
{
{ IssuerKey, IssuerValue },
{ EndpointKey, endpoint.Host },
{ DnsProviderKey, certificatePolicyItem.DnsProviderName }
};

if (!string.IsNullOrEmpty(certificatePolicyItem.DnsAlias))
{
metadata.Add(DnsAliasKey, certificatePolicyItem.DnsAlias);
}

return metadata;
}

private const string IssuerKey = "Issuer";
private const string EndpointKey = "Endpoint";
private const string DnsProviderKey = "DnsProvider";
Expand All @@ -75,7 +92,6 @@ public static CertificatePolicyItem ToCertificatePolicyItem(this KeyVaultCertifi

private static bool TryGetDnsAlias(this IDictionary<string, string> tags, out string dnsAlias) => tags.TryGetValue(DnsAliasKey, out dnsAlias);


private static string ToHexString(byte[] bytes)
{
ArgumentNullException.ThrowIfNull(bytes);
Expand Down
Loading