Skip to content

Commit

Permalink
Merge pull request #16 from Keyfactor/optionalsubjectchecks
Browse files Browse the repository at this point in the history
Allow subject checks to be optional
  • Loading branch information
dgaley authored Jun 14, 2022
2 parents a92a352 + aba6f8b commit e1a9129
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/SectigoCAProxy/SectigoCAProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ public override EnrollmentResult Enroll(ICertificateDataReader certificateDataRe
string orgStr = ParseSubject(subject, "O=");
Logger.Trace($"Organization: {orgStr}");

string ouStr = ParseSubject(subject, "OU=");
string ouStr = ParseSubject(subject, "OU=", false);

string department = productInfo.ProductParameters["Department"];
Logger.Trace($"Department: {department}");
Expand Down Expand Up @@ -619,7 +619,7 @@ private static string ParseSanList(Dictionary<string, string[]> san, bool multiD
return sanList;
}

private static string ParseSubject(string subject, string rdn)
private static string ParseSubject(string subject, string rdn, bool required = true)
{
string escapedSubject = subject.Replace("\\,", "|");
string rdnString = escapedSubject.Split(',').ToList().Where(x => x.Contains(rdn)).FirstOrDefault();
Expand All @@ -628,10 +628,14 @@ private static string ParseSubject(string subject, string rdn)
{
return rdnString.Replace(rdn, "").Replace("|", ",").Trim();
}
else
else if (required)
{
throw new Exception($"The request is missing a {rdn} value");
}
else
{
return null;
}
}

/// <summary>
Expand Down

0 comments on commit e1a9129

Please sign in to comment.