diff --git a/src/SectigoCAProxy/SectigoCAProxy.cs b/src/SectigoCAProxy/SectigoCAProxy.cs index c779ef2..e99cfe4 100644 --- a/src/SectigoCAProxy/SectigoCAProxy.cs +++ b/src/SectigoCAProxy/SectigoCAProxy.cs @@ -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}"); @@ -619,7 +619,7 @@ private static string ParseSanList(Dictionary 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(); @@ -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; + } } ///