Skip to content

Commit

Permalink
Close #402: Subject Alternative Name not filled by all CN
Browse files Browse the repository at this point in the history
Iterate over all CN and add them to the SAN.
  • Loading branch information
chris2511 committed Oct 12, 2023
1 parent 6cfd017 commit d36b32f
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/x509v3ext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,15 @@ x509v3ext &x509v3ext::create(int nid, const QString &et, X509V3_CTX *ctx)
nid == NID_subject_alt_name)
{
x509name xn(X509_get_subject_name(ctx->subject_cert));
QString cn = xn.getEntryByNid(NID_commonName);
if (!cn.isEmpty())
etext.replace(QString("DNS:copycn"),
QString("DNS:%1").arg(cn));
QStringList new_san;
int i, max = xn.entryCount();
for (i=0; i < max; i++) {
if (xn.nid(i) == NID_commonName)
new_san << QString("DNS:%1").arg(xn.getEntry(i));
}
qDebug() << "COUNT" << new_san.size() << new_san.join(",");
if (new_san.size() > 0)
etext.replace(QString("DNS:copycn"), new_san.join(","));
}
QByteArray ba = etext.toLocal8Bit();
ext = X509V3_EXT_conf_nid(NULL, ctx, nid, ba.data());
Expand Down

0 comments on commit d36b32f

Please sign in to comment.