Skip to content

Commit 916fe52

Browse files
committed
Print DirName differently in SAN's
When printing SubjectAlternativeNames, print the details of DirName entries in a different format than GENERAL_NAME_print() to avoid parsing issues due to commas.
1 parent 2523491 commit 916fe52

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

ext/openssl/openssl_backend_common.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,9 +667,29 @@ int openssl_x509v3_subjectAltName(BIO *bio, X509_EXTENSION *extension)
667667
BIO_write(bio, ASN1_STRING_get0_data(as),
668668
ASN1_STRING_length(as));
669669
break;
670+
case GEN_DIRNAME:
671+
BIO_puts(bio, "DirName:");
672+
char *ptr = X509_NAME_oneline(name->d.dirn, 0, 0);
673+
char *p = ptr;
674+
char *q;
675+
while (*p) {
676+
q = strchr(p, ',');
677+
if (q) {
678+
*q = '\0';
679+
BIO_puts(bio, p);
680+
BIO_puts(bio, "\\,");
681+
p = q+1;
682+
} else {
683+
BIO_puts(bio, p);
684+
*p = '\0';
685+
}
686+
}
687+
BIO_puts(bio, "\n");
688+
OPENSSL_free(ptr);
689+
break;
670690
default:
671691
/* use builtin print for GEN_OTHERNAME, GEN_X400,
672-
* GEN_EDIPARTY, GEN_DIRNAME, GEN_IPADD and GEN_RID
692+
* GEN_EDIPARTY, GEN_IPADD and GEN_RID
673693
*/
674694
GENERAL_NAME_print(bio, name);
675695
}

0 commit comments

Comments
 (0)