From aba6f8b38c05639b58f592e9b37d14c1bb149a2b Mon Sep 17 00:00:00 2001 From: David Galey Date: Tue, 14 Jun 2022 13:05:24 -0400 Subject: [PATCH] Allow subject checks to be optional --- src/SectigoCAProxy/SectigoCAProxy.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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; + } } ///