Skip to content
Merged
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
49 changes: 29 additions & 20 deletions globalsign-mssl-caplugin/GlobalSignCAPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
Config.SyncIntervalDays);

bool productFilter = false;
List<string> products = null;

Check warning on line 111 in globalsign-mssl-caplugin/GlobalSignCAPlugin.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

Converting null literal or possible null value to non-nullable type.

Check warning on line 111 in globalsign-mssl-caplugin/GlobalSignCAPlugin.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

Converting null literal or possible null value to non-nullable type.

Check warning on line 111 in globalsign-mssl-caplugin/GlobalSignCAPlugin.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

Converting null literal or possible null value to non-nullable type.
if (!string.IsNullOrEmpty(Config.SyncProducts))
{
products = Config.SyncProducts.Split(',').ToList();
Expand All @@ -121,7 +121,7 @@
if (productFilter)
{
bool prodMatch = false;
if (c.OrderInfo?.ProductCode != null && products.Contains(c.OrderInfo.ProductCode.ToUpper()))

Check warning on line 124 in globalsign-mssl-caplugin/GlobalSignCAPlugin.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

Dereference of a possibly null reference.

Check warning on line 124 in globalsign-mssl-caplugin/GlobalSignCAPlugin.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

Dereference of a possibly null reference.

Check warning on line 124 in globalsign-mssl-caplugin/GlobalSignCAPlugin.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

Dereference of a possibly null reference.
{
prodMatch = true;
}
Expand Down Expand Up @@ -225,12 +225,12 @@
privateDomain = bool.TryParse(prD, out var parsedD) && parsedD;
if (privateDomain)
{
if (!productInfo.ProductParameters.TryGetValue("RequesterEmail", out requesterEmail) || string.IsNullOrWhiteSpace(requesterEmail))

Check warning on line 228 in globalsign-mssl-caplugin/GlobalSignCAPlugin.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

Converting null literal or possible null value to non-nullable type.

Check warning on line 228 in globalsign-mssl-caplugin/GlobalSignCAPlugin.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

Converting null literal or possible null value to non-nullable type.

Check warning on line 228 in globalsign-mssl-caplugin/GlobalSignCAPlugin.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

Converting null literal or possible null value to non-nullable type.
{
Logger.LogWarning("The 'RequesterEmail' parameter is required when 'PrivateDomain' is true but was not provided or is empty.");
requesterEmail = string.Empty;
}
if (!productInfo.ProductParameters.TryGetValue("RequesterTel", out requesterTel) || string.IsNullOrWhiteSpace(requesterTel))

Check warning on line 233 in globalsign-mssl-caplugin/GlobalSignCAPlugin.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

Converting null literal or possible null value to non-nullable type.

Check warning on line 233 in globalsign-mssl-caplugin/GlobalSignCAPlugin.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

Converting null literal or possible null value to non-nullable type.

Check warning on line 233 in globalsign-mssl-caplugin/GlobalSignCAPlugin.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

Converting null literal or possible null value to non-nullable type.
{
Logger.LogWarning("The 'RequesterTel' parameter is required when 'PrivateDomain' is true but was not provided or is empty.");
requesterTel = string.Empty;
Expand All @@ -246,7 +246,7 @@
GetDomainsDomainDetail? domain = null;
var allDomains = await apiClient.GetDomains();
var validDomainStatus = new List<string> { "3", "7", "9", "10" };
//var validDomains = allDomains.Where(d => validDomainStatus.Contains(d.DomainStatus)).ToList();
var validDomains = allDomains.Where(d => validDomainStatus.Contains(d.DomainStatus)).ToList();
//if (validDomains.Count == 0 && !privateDomain)
// throw new Exception("No domains found that are valid for certificate enrollment");
try
Expand Down Expand Up @@ -342,7 +342,7 @@

}
};
domain.MSSLProfileID = fillProfile.MSSLProfileId;

Check warning on line 345 in globalsign-mssl-caplugin/GlobalSignCAPlugin.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

Dereference of a possibly null reference.

Check warning on line 345 in globalsign-mssl-caplugin/GlobalSignCAPlugin.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

Dereference of a possibly null reference.

Check warning on line 345 in globalsign-mssl-caplugin/GlobalSignCAPlugin.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

Dereference of a possibly null reference.
matchedDomains = new List<GetDomainsDomainDetail> { domain };
}

Expand Down Expand Up @@ -372,34 +372,43 @@
}
else
{
StringBuilder sb = new StringBuilder();
sb.AppendLine($"Domains found matching common name {commonName}:");
foreach (var dom in matchedDomains)
var validMatchedDomains = matchedDomains.FindAll(d => validDomains.Contains(d)).ToList();
matchedDomains = validMatchedDomains;
if (matchedDomains.Count == 1)
{
sb.AppendLine($"Domain: {dom.DomainName}\tProfileID: {dom.MSSLProfileID}");
domain = matchedDomains[0];
}
//Logger.LogTrace($"Multiple domains found matching common name {commonName}:\n{string.Join(',', matchedDomains.Select(d => d.DomainName))}.\nChecking for Profile ID.");
var profId = productInfo.ProductParameters["MSSLProfileID"];
if (!string.IsNullOrEmpty(profId))
else
{
sb.AppendLine($"Comparing ProfileID to provided MSSLProfileID: {profId}");
Logger.LogTrace(sb.ToString());
var tempDomain = matchedDomains.Where(d =>
d.MSSLProfileID.Equals(profId, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
if (tempDomain != null)
StringBuilder sb = new StringBuilder();
sb.AppendLine($"Domains found matching common name {commonName}:");
foreach (var dom in matchedDomains)
{
sb.AppendLine($"Domain: {dom.DomainName}\tProfileID: {dom.MSSLProfileID}");
}
//Logger.LogTrace($"Multiple domains found matching common name {commonName}:\n{string.Join(',', matchedDomains.Select(d => d.DomainName))}.\nChecking for Profile ID.");
var profId = productInfo.ProductParameters["MSSLProfileID"];
if (!string.IsNullOrEmpty(profId))
{
domain = tempDomain;
sb.AppendLine($"Comparing ProfileID to provided MSSLProfileID: {profId}");
Logger.LogTrace(sb.ToString());
var tempDomain = matchedDomains.Where(d =>
d.MSSLProfileID.Equals(profId, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
if (tempDomain != null)
{
domain = tempDomain;
}
else
{
throw new Exception($"No domain matching common name {commonName} has provided MSSLProfileID of {profId}. Check configuration.");
}
}
else
{
throw new Exception($"No domain matching common name {commonName} has provided MSSLProfileID of {profId}. Check configuration.");
sb.AppendLine("No MSSLProfileID provided, unable to determine correct domain");
Logger.LogTrace(sb.ToString());
}
}
else
{
sb.AppendLine("No MSSLProfileID provided, unable to determine correct domain");
Logger.LogTrace(sb.ToString());
}
}


Expand Down Expand Up @@ -438,7 +447,7 @@
throw new Exception($"Failed to resolve domain validator for domain {domain.DomainName}: {ex.Message}", ex);
}

DomainValidationResult domValResult = null;

Check warning on line 450 in globalsign-mssl-caplugin/GlobalSignCAPlugin.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

Converting null literal or possible null value to non-nullable type.

Check warning on line 450 in globalsign-mssl-caplugin/GlobalSignCAPlugin.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

Converting null literal or possible null value to non-nullable type.

Check warning on line 450 in globalsign-mssl-caplugin/GlobalSignCAPlugin.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

Converting null literal or possible null value to non-nullable type.
domValResult = await validator.StageValidation(domain.DomainName, dnsTxt, CancellationToken.None);

if (domValResult == null || !domValResult.Success)
Expand Down Expand Up @@ -503,7 +512,7 @@
case EnrollmentType.RenewOrReissue:
//Determine whether this is a renewal or a reissue:
var renewal = false;
var order_id = await _certificateDataReader.GetRequestIDBySerialNumber(priorSn);

Check warning on line 515 in globalsign-mssl-caplugin/GlobalSignCAPlugin.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

Dereference of a possibly null reference.

Check warning on line 515 in globalsign-mssl-caplugin/GlobalSignCAPlugin.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

Dereference of a possibly null reference.

Check warning on line 515 in globalsign-mssl-caplugin/GlobalSignCAPlugin.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

Dereference of a possibly null reference.
var expirationDate = _certificateDataReader.GetExpirationDateByRequestId(order_id);
if (expirationDate == null)
{
Expand All @@ -511,7 +520,7 @@
expirationDate = localcert.RevocationDate;
}

if (expirationDate.Value.AddDays(-30) < DateTime.Now) renewal = true; // 30 day renewal window

Check warning on line 523 in globalsign-mssl-caplugin/GlobalSignCAPlugin.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

Nullable value type may be null.

Check warning on line 523 in globalsign-mssl-caplugin/GlobalSignCAPlugin.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

Nullable value type may be null.

Check warning on line 523 in globalsign-mssl-caplugin/GlobalSignCAPlugin.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

Nullable value type may be null.
if (renewal)
{
Logger.LogDebug(
Expand Down
Loading