libsec: take just the CN part of Distinguished Name in subjectAltName

This commit is contained in:
cinap_lenrek 2021-07-08 20:20:09 +00:00
parent 8b550e73c2
commit b542dce430

View file

@ -1906,7 +1906,8 @@ decode_cert(uchar *buf, int len)
el = el->tl; el = el->tl;
epubkey = &el->hd; epubkey = &el->hd;
if(el->tl != nil if(el->tl != nil
&& el->tl->hd.tag.class == Context && el->tl->hd.tag.num == 3 && el->tl->hd.tag.class == Context
&& el->tl->hd.tag.num == 3
&& el->tl->hd.val.tag == VOctets){ && el->tl->hd.val.tag == VOctets){
c->ext = el->tl->hd.val.u.octetsval; c->ext = el->tl->hd.val.u.octetsval;
el->tl->hd.val.u.octetsval = nil; /* transfer ownership */ el->tl->hd.val.u.octetsval = nil; /* transfer ownership */
@ -2700,7 +2701,7 @@ appendaltnames(char *name, int nname, Bytes *ext, int isreq)
Elem eext, ealt, edn; Elem eext, ealt, edn;
Elist *el, *l; Elist *el, *l;
Ints *oid; Ints *oid;
char *alt; char *alt, *e;
int len; int len;
if(name == nil || ext == nil) if(name == nil || ext == nil)
@ -2758,6 +2759,9 @@ appendaltnames(char *name, int nname, Bytes *ext, int isreq)
} }
if(alt == nil) if(alt == nil)
goto erralt; goto erralt;
/* take just CN part of Distinguished Name */
if((e = strchr(alt, ',')) != nil)
*e = '\0';
len = strlen(alt); len = strlen(alt);
if(strncmp(name, alt, len) == 0 && strchr(",", name[len]) != nil){ if(strncmp(name, alt, len) == 0 && strchr(",", name[len]) != nil){
free(alt); /* same as the subject */ free(alt); /* same as the subject */