Allow empty values when parsing distinguished name (#26627)

This commit is contained in:
Sarah Gillespie 2025-02-26 15:59:20 -06:00 committed by GitHub
parent b2bf148b65
commit e02ad241ea
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 5 deletions

View file

@ -203,10 +203,6 @@ func ExtractDetailsFromOsqueryDistinguishedName(str string) (*HostCertificateNam
return nil, errors.New("invalid distinguished name, wrong key value pair format")
}
if len(kv[1]) == 0 {
return nil, errors.New("invalid distinguished name, missing value")
}
switch strings.ToUpper(kv[0]) {
case "C":
details.Country = strings.Trim(kv[1], " ")

View file

@ -73,7 +73,12 @@ func TestExtractHostCertificateNameDetails(t *testing.T) {
{
name: "missing value",
input: "/C=US/O=Fleet Device Management Inc./OU=Fleet Device Management Inc./CN=",
err: true,
expected: &HostCertificateNameDetails{
Country: "US",
Organization: "Fleet Device Management Inc.",
OrganizationalUnit: "Fleet Device Management Inc.",
CommonName: "",
},
},
{
name: "missing first slash",