Skip to content

Commit

Permalink
piv-certs: allow multiple UPN SANs
Browse files Browse the repository at this point in the history
  • Loading branch information
arekinath committed Dec 10, 2024
1 parent 95ad3ee commit 9e25e40
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions piv-certs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1359,22 +1359,28 @@ add_common_princs(struct cert_var_scope *cs, STACK_OF(GENERAL_NAME) *gns)

if (upn != NULL) {
ASN1_UTF8STRING *str;
char *saveptr = NULL, *token;

obj = OBJ_txt2obj("1.3.6.1.4.1.311.20.2.3", 1);
VERIFY(obj != NULL);
token = strtok_r(upn, ",; ", &saveptr);
while (token != NULL) {
obj = OBJ_txt2obj("1.3.6.1.4.1.311.20.2.3", 1);
VERIFY(obj != NULL);

str = ASN1_UTF8STRING_new();
VERIFY(str != NULL);
VERIFY(ASN1_STRING_set(str, upn, -1) == 1);
str = ASN1_UTF8STRING_new();
VERIFY(str != NULL);
VERIFY(ASN1_STRING_set(str, token, -1) == 1);

typ = ASN1_TYPE_new();
VERIFY(typ != NULL);
ASN1_TYPE_set(typ, V_ASN1_UTF8STRING, str);
typ = ASN1_TYPE_new();
VERIFY(typ != NULL);
ASN1_TYPE_set(typ, V_ASN1_UTF8STRING, str);

gn = GENERAL_NAME_new();
VERIFY(gn != NULL);
VERIFY(GENERAL_NAME_set0_othername(gn, obj, typ) == 1);
VERIFY(sk_GENERAL_NAME_push(gns, gn) != 0);
gn = GENERAL_NAME_new();
VERIFY(gn != NULL);
VERIFY(GENERAL_NAME_set0_othername(gn, obj, typ) == 1);
VERIFY(sk_GENERAL_NAME_push(gns, gn) != 0);

token = strtok_r(NULL, ",; ", &saveptr);
}
}
free(upn);

Expand Down

0 comments on commit 9e25e40

Please sign in to comment.