ref: b542dce430d408ed1f7457a26caa1d4bfc7339c4
parent: 8b550e73c2cadcbd0df165c5474241d6b60dfce8
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Thu Jul 8 16:20:09 EDT 2021
libsec: take just the CN part of Distinguished Name in subjectAltName
--- a/sys/src/libsec/port/x509.c
+++ b/sys/src/libsec/port/x509.c
@@ -1906,7 +1906,8 @@
el = el->tl;
epubkey = &el->hd;
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){
c->ext = el->tl->hd.val.u.octetsval;
el->tl->hd.val.u.octetsval = nil; /* transfer ownership */
@@ -2700,7 +2701,7 @@
Elem eext, ealt, edn;
Elist *el, *l;
Ints *oid;
- char *alt;
+ char *alt, *e;
int len;
if(name == nil || ext == nil)
@@ -2758,6 +2759,9 @@
}
if(alt == nil)
goto erralt;
+ /* take just CN part of Distinguished Name */
+ if((e = strchr(alt, ',')) != nil)
+ *e = '\0';
len = strlen(alt);
if(strncmp(name, alt, len) == 0 && strchr(",", name[len]) != nil){
free(alt); /* same as the subject */