Skip to content

Commit b0f7c77

Browse files
Removed Inline DNS Providers
1 parent d3e2bc6 commit b0f7c77

15 files changed

+466
-1545
lines changed

AcmeCaPlugin.sln

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,52 @@ EndProject
1010
Global
1111
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1212
Debug|Any CPU = Debug|Any CPU
13+
Debug|x64 = Debug|x64
14+
Debug|x86 = Debug|x86
1315
Prerelease|Any CPU = Prerelease|Any CPU
16+
Prerelease|x64 = Prerelease|x64
17+
Prerelease|x86 = Prerelease|x86
1418
Release|Any CPU = Release|Any CPU
19+
Release|x64 = Release|x64
20+
Release|x86 = Release|x86
1521
EndGlobalSection
1622
GlobalSection(ProjectConfigurationPlatforms) = postSolution
1723
{011DC646-BEF9-4D3B-9D20-CA444A26B355}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1824
{011DC646-BEF9-4D3B-9D20-CA444A26B355}.Debug|Any CPU.Build.0 = Debug|Any CPU
25+
{011DC646-BEF9-4D3B-9D20-CA444A26B355}.Debug|x64.ActiveCfg = Debug|Any CPU
26+
{011DC646-BEF9-4D3B-9D20-CA444A26B355}.Debug|x64.Build.0 = Debug|Any CPU
27+
{011DC646-BEF9-4D3B-9D20-CA444A26B355}.Debug|x86.ActiveCfg = Debug|Any CPU
28+
{011DC646-BEF9-4D3B-9D20-CA444A26B355}.Debug|x86.Build.0 = Debug|Any CPU
1929
{011DC646-BEF9-4D3B-9D20-CA444A26B355}.Prerelease|Any CPU.ActiveCfg = Release|Any CPU
2030
{011DC646-BEF9-4D3B-9D20-CA444A26B355}.Prerelease|Any CPU.Build.0 = Release|Any CPU
31+
{011DC646-BEF9-4D3B-9D20-CA444A26B355}.Prerelease|x64.ActiveCfg = Prerelease|Any CPU
32+
{011DC646-BEF9-4D3B-9D20-CA444A26B355}.Prerelease|x64.Build.0 = Prerelease|Any CPU
33+
{011DC646-BEF9-4D3B-9D20-CA444A26B355}.Prerelease|x86.ActiveCfg = Prerelease|Any CPU
34+
{011DC646-BEF9-4D3B-9D20-CA444A26B355}.Prerelease|x86.Build.0 = Prerelease|Any CPU
2135
{011DC646-BEF9-4D3B-9D20-CA444A26B355}.Release|Any CPU.ActiveCfg = Release|Any CPU
2236
{011DC646-BEF9-4D3B-9D20-CA444A26B355}.Release|Any CPU.Build.0 = Release|Any CPU
37+
{011DC646-BEF9-4D3B-9D20-CA444A26B355}.Release|x64.ActiveCfg = Release|Any CPU
38+
{011DC646-BEF9-4D3B-9D20-CA444A26B355}.Release|x64.Build.0 = Release|Any CPU
39+
{011DC646-BEF9-4D3B-9D20-CA444A26B355}.Release|x86.ActiveCfg = Release|Any CPU
40+
{011DC646-BEF9-4D3B-9D20-CA444A26B355}.Release|x86.Build.0 = Release|Any CPU
2341
{F45D27E5-26B8-435B-AC49-5A119094BFD3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
2442
{F45D27E5-26B8-435B-AC49-5A119094BFD3}.Debug|Any CPU.Build.0 = Debug|Any CPU
43+
{F45D27E5-26B8-435B-AC49-5A119094BFD3}.Debug|x64.ActiveCfg = Debug|Any CPU
44+
{F45D27E5-26B8-435B-AC49-5A119094BFD3}.Debug|x64.Build.0 = Debug|Any CPU
45+
{F45D27E5-26B8-435B-AC49-5A119094BFD3}.Debug|x86.ActiveCfg = Debug|Any CPU
46+
{F45D27E5-26B8-435B-AC49-5A119094BFD3}.Debug|x86.Build.0 = Debug|Any CPU
2547
{F45D27E5-26B8-435B-AC49-5A119094BFD3}.Prerelease|Any CPU.ActiveCfg = Debug|Any CPU
2648
{F45D27E5-26B8-435B-AC49-5A119094BFD3}.Prerelease|Any CPU.Build.0 = Debug|Any CPU
49+
{F45D27E5-26B8-435B-AC49-5A119094BFD3}.Prerelease|x64.ActiveCfg = Prerelease|Any CPU
50+
{F45D27E5-26B8-435B-AC49-5A119094BFD3}.Prerelease|x64.Build.0 = Prerelease|Any CPU
51+
{F45D27E5-26B8-435B-AC49-5A119094BFD3}.Prerelease|x86.ActiveCfg = Prerelease|Any CPU
52+
{F45D27E5-26B8-435B-AC49-5A119094BFD3}.Prerelease|x86.Build.0 = Prerelease|Any CPU
2753
{F45D27E5-26B8-435B-AC49-5A119094BFD3}.Release|Any CPU.ActiveCfg = Release|Any CPU
2854
{F45D27E5-26B8-435B-AC49-5A119094BFD3}.Release|Any CPU.Build.0 = Release|Any CPU
55+
{F45D27E5-26B8-435B-AC49-5A119094BFD3}.Release|x64.ActiveCfg = Release|Any CPU
56+
{F45D27E5-26B8-435B-AC49-5A119094BFD3}.Release|x64.Build.0 = Release|Any CPU
57+
{F45D27E5-26B8-435B-AC49-5A119094BFD3}.Release|x86.ActiveCfg = Release|Any CPU
58+
{F45D27E5-26B8-435B-AC49-5A119094BFD3}.Release|x86.Build.0 = Release|Any CPU
2959
EndGlobalSection
3060
GlobalSection(SolutionProperties) = preSolution
3161
HideSolutionNode = FALSE

AcmeCaPlugin/AcmeCaPlugin.cs

Lines changed: 42 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
using Keyfactor.PKI.Enums.EJBCA;
1111
using Microsoft.Extensions.Logging;
1212
using Newtonsoft.Json;
13-
using Org.BouncyCastle.Asn1;
1413
using Org.BouncyCastle.Asn1.Pkcs;
1514
using Org.BouncyCastle.Asn1.X509;
1615
using Org.BouncyCastle.Pkcs;
@@ -22,7 +21,6 @@
2221
using System.Text.RegularExpressions;
2322
using System.Threading;
2423
using System.Threading.Tasks;
25-
using static Org.BouncyCastle.Math.EC.ECCurve;
2624

2725
namespace Keyfactor.Extensions.CAPlugin.Acme
2826
{
@@ -73,19 +71,13 @@ public class AcmeCaPlugin : IAnyCAPlugin
7371
private const string USER_AGENT = "KeyfactorAcmePlugin/1.0";
7472

7573
/// <summary>
76-
/// Default constructor for backward compatibility
74+
/// Constructor requires domain validator factory for plugin-based DNS providers
7775
/// </summary>
78-
public AcmeCaPlugin() : this(null)
79-
{
80-
}
81-
82-
/// <summary>
83-
/// Constructor with dependency injection support for domain validator factory
84-
/// </summary>
85-
/// <param name="validatorFactory">Factory to resolve domain validators from plugins</param>
76+
/// <param name="validatorFactory">Factory to resolve domain validators from plugins (Required)</param>
8677
public AcmeCaPlugin(IDomainValidatorFactory validatorFactory)
8778
{
88-
_validatorFactory = validatorFactory;
79+
_validatorFactory = validatorFactory ?? throw new ArgumentNullException(nameof(validatorFactory),
80+
"IDomainValidatorFactory is required. DNS providers are now externalized as plugins.");
8981
}
9082

9183
/// <summary>
@@ -96,43 +88,54 @@ public void Initialize(IAnyCAPluginConfigProvider configProvider, ICertificateDa
9688
_logger.MethodEntry();
9789
Config = configProvider ?? throw new ArgumentNullException(nameof(configProvider));
9890

99-
// Try to use plugin-based domain validator if factory is available
100-
if (_validatorFactory != null)
91+
// Factory is now required - all DNS providers are externalized as plugins
92+
if (_validatorFactory == null)
10193
{
102-
_logger.LogInformation("Using plugin-based domain validator resolution");
103-
try
104-
{
105-
// Resolve domain validator from plugin system
106-
_domainValidator = _validatorFactory.ResolveDomainValidator(
107-
domain: "www.keyfactortestb.com", // Wildcard - let the factory choose the right provider
108-
validationType: DNS_CHALLENGE_TYPE
109-
);
110-
111-
if (_domainValidator != null)
112-
{
113-
//_domainValidator.Initialize(new DomainValidatorConfigProvider(configProvider.CAConnectionData));
114-
_logger.LogInformation("Successfully initialized domain validator from plugin: {ValidatorType}",
115-
_domainValidator.GetType().FullName);
116-
}
117-
}
118-
catch (Exception ex)
119-
{
120-
_logger.LogWarning(ex, "Failed to resolve domain validator from plugin factory, falling back to embedded validator");
121-
_domainValidator = null;
122-
}
94+
var errorMsg = "IDomainValidatorFactory is required. DNS providers are now loaded as external plugins. " +
95+
"Ensure the Keyfactor platform is configured to inject the factory.";
96+
_logger.LogError(errorMsg);
97+
throw new InvalidOperationException(errorMsg);
12398
}
12499

125-
// Fallback to embedded validator for backward compatibility
100+
_logger.LogInformation("Resolving domain validator from plugin system");
101+
102+
// Resolve domain validator from plugin system
103+
_domainValidator = _validatorFactory.ResolveDomainValidator(
104+
domain: "*", // Wildcard - let the factory choose based on configuration
105+
validationType: DNS_CHALLENGE_TYPE
106+
);
107+
126108
if (_domainValidator == null)
127109
{
128-
_logger.LogInformation("Using embedded Dns01DomainValidator (legacy mode)");
129-
_domainValidator = new Dns01DomainValidator();
130-
_domainValidator.Initialize(new DomainValidatorConfigProvider(configProvider.CAConnectionData));
110+
var errorMsg = $"Failed to resolve domain validator for type '{DNS_CHALLENGE_TYPE}'. " +
111+
"Ensure the appropriate DNS provider plugin is deployed and configured.";
112+
_logger.LogError(errorMsg);
113+
throw new InvalidOperationException(errorMsg);
131114
}
132115

116+
// Initialize the validator with configuration
117+
var domainValidatorConfig = new DomainValidatorConfigProvider(configProvider.CAConnectionData);
118+
_domainValidator.Initialize(domainValidatorConfig);
119+
120+
_logger.LogInformation("Successfully initialized domain validator from plugin: {ValidatorType}",
121+
_domainValidator.GetType().FullName);
122+
133123
_logger.MethodExit();
134124
}
135125

126+
/// <summary>
127+
/// Simple implementation of IDomainValidatorConfigProvider to pass configuration to plugins
128+
/// </summary>
129+
private class DomainValidatorConfigProvider : IDomainValidatorConfigProvider
130+
{
131+
public Dictionary<string, object> DomainValidationConfiguration { get; }
132+
133+
public DomainValidatorConfigProvider(Dictionary<string, object> config)
134+
{
135+
DomainValidationConfiguration = config ?? new Dictionary<string, object>();
136+
}
137+
}
138+
136139
/// <summary>
137140
/// Health check method - currently no-op for ACME
138141
/// </summary>

AcmeCaPlugin/AcmeClientConfig.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using Amazon;
2-
3-
namespace Keyfactor.Extensions.CAPlugin.Acme
1+
namespace Keyfactor.Extensions.CAPlugin.Acme
42
{
53
public class AcmeClientConfig
64
{

AcmeCaPlugin/Clients/DNS/AwsRoute53DnsProvider.cs

Lines changed: 0 additions & 171 deletions
This file was deleted.

0 commit comments

Comments
 (0)