Skip to content

Commit d303caf

Browse files
Merge 49d2d6f into 9545626
2 parents 9545626 + 49d2d6f commit d303caf

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

AcmeCaPlugin/AcmeCaPlugin.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,10 +321,14 @@ private static string ExtractDomainFromSubject(string subject)
321321
if (string.IsNullOrWhiteSpace(subject))
322322
throw new ArgumentException("Subject cannot be null or empty", nameof(subject));
323323

324-
return subject
325-
.Replace("CN=", "", StringComparison.OrdinalIgnoreCase)
326-
.Replace("cn=", "", StringComparison.OrdinalIgnoreCase)
327-
.Trim();
324+
// Match CN=value (capturing everything until comma or end of string)
325+
var match = Regex.Match(subject, @"CN=([^,]+)", RegexOptions.IgnoreCase);
326+
if (match.Success)
327+
{
328+
return match.Groups[1].Value.Trim();
329+
}
330+
331+
throw new ArgumentException($"Could not extract CN from subject: {subject}", nameof(subject));
328332
}
329333

330334
/// <summary>

0 commit comments

Comments
 (0)