Skip to content

Commit b4f157e

Browse files
Implement ACME Profiles (draft)
1 parent 8ca8d17 commit b4f157e

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

src/Certify.Models/Config/CertRequestConfig.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Collections.ObjectModel;
44
using System.Linq;
@@ -301,6 +301,11 @@ public CertRequestConfig()
301301
/// </summary>
302302
public float? PreferredExpiryDays { get; set; }
303303

304+
/// <summary>
305+
/// If set, specifies the preferred ACME profile to request (if the selected CA offers a profile with this name)
306+
/// </summary>
307+
public string? AcmeProfile { get; set; }
308+
304309
public void ApplyDeploymentOptionDefaults()
305310
{
306311
// if the selected mode is auto, discard settings which do not apply

src/Certify.Providers/ACME/Anvil/AnvilACMEProvider.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,8 +754,12 @@ public async Task<PendingOrder> BeginCertificateOrder(ILog log, ManagedCertifica
754754
var orderCreated = false;
755755
var orderAttemptAbandoned = false;
756756
object lastException = null;
757+
757758
var caSupportsARI = false;
758759

760+
var caSupportsRequestedProfile = false;
761+
var profile = managedCertificate.RequestConfig.AcmeProfile?.Trim();
762+
759763
try
760764
{
761765
// first check we can access the ACME API
@@ -766,6 +770,16 @@ public async Task<PendingOrder> BeginCertificateOrder(ILog log, ManagedCertifica
766770
{
767771
caSupportsARI = true;
768772
}
773+
774+
if (!string.IsNullOrWhiteSpace(profile) && dir.Meta?.Profiles.ContainsKey(profile) == true)
775+
{
776+
caSupportsRequestedProfile = true;
777+
log?.Information($"The CA supports the specified ACME Profile [{profile}].");
778+
}
779+
else
780+
{
781+
log?.Error($"CA does not support the specified ACME Profile [{profile}]. The order will continue without a specific profile.");
782+
}
769783
}
770784
catch (Exception exp)
771785
{
@@ -828,7 +842,7 @@ public async Task<PendingOrder> BeginCertificateOrder(ILog log, ManagedCertifica
828842
ariReplacesCertId = managedCertificate.ARICertificateId;
829843
}
830844

831-
order = await _acme.NewOrder(identifiers: certificateIdentifiers, notAfter: notAfter, ariReplacesCertId: ariReplacesCertId);
845+
order = await _acme.NewOrder(identifiers: certificateIdentifiers, notAfter: notAfter, ariReplacesCertId: ariReplacesCertId, profile: caSupportsRequestedProfile ? profile : null);
832846
}
833847

834848
if (order != null)

src/Certify.UI.Shared/Controls/ManagedCertificate/AdvancedOptions.xaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,23 @@
8888
Width="200"
8989
HorizontalAlignment="left"
9090
Controls:TextBoxHelper.Watermark="e.g. DST Root CA X3"
91+
DockPanel.Dock="Top"
9192
Text="{Binding SelectedItem.RequestConfig.PreferredChain}" />
93+
<TextBlock
94+
Margin="0,8"
95+
DockPanel.Dock="Top"
96+
Style="{StaticResource Subheading}">
97+
ACME Profile (Draft)
98+
</TextBlock>
99+
<TextBlock DockPanel.Dock="Top" Style="{StaticResource Instructions}">
100+
The certificate authority may allow you to specify a preset "profile" name for your certificate order.
101+
</TextBlock>
102+
<TextBox
103+
Width="200"
104+
HorizontalAlignment="left"
105+
Controls:TextBoxHelper.Watermark="e.g. classic"
106+
DockPanel.Dock="Top"
107+
Text="{Binding SelectedItem.RequestConfig.AcmeProfile}" />
92108
</DockPanel>
93109
</TabItem>
94110

0 commit comments

Comments
 (0)