From e9aed242ccf6c569491b34e5455e9ea9b78cd29a Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Sun, 20 Jun 2021 23:33:13 +0000 Subject: [PATCH 1/1] libsec: emulate openssl asn1 when generating x509 csr when trying to request certificates from letsencrypt, their test api would reject our csr because of "tuncated sequence" unless we force subectAltName by passing multiple domains (as comma separated list). apparently, we need to provide the context specific tag "cont [ 0 ]" for the extensions even when we do have any extensions for the csr (triggered when we need to have subjectAltNames). for this, we change mkcont() to take a Elist* instead, which then can be nil when not used. also put the tag number argument first, which makes it easier to read. --- sys/src/libsec/port/x509.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/sys/src/libsec/port/x509.c b/sys/src/libsec/port/x509.c index 5b4d24952..404d64ff3 100644 --- a/sys/src/libsec/port/x509.c +++ b/sys/src/libsec/port/x509.c @@ -2576,9 +2576,9 @@ asn1encodedigest(DigestState* (*fun)(uchar*, ulong, uchar*, DigestState*), uchar } static Elem -mkcont(Elem e, int num) +mkcont(int num, Elist *l) { - e = mkseq(mkel(e, nil)); + Elem e = mkseq(l); e.tag.class = Context; e.tag.num = num; return e; @@ -2592,7 +2592,7 @@ mkaltname(char *s) for(i=0; idata, pkbytes->len), nil))), - mkextensions(alts, 0))))))))); + mkel(mkcont(3, mkextensions(alts, 0)), nil))))))))); freebytes(pkbytes); if(encode(e, &certinfobytes) != ASN_OK) goto errret; @@ -2842,7 +2843,7 @@ X509rsareq(RSApriv *priv, char *subj, int *certlen) mkel(mkalg(ALG_rsaEncryption), mkel(mkbits(pkbytes->data, pkbytes->len), nil))), - mkextensions(alts, 1))))); + mkel(mkcont(0, mkextensions(alts, 1)), nil))))); freebytes(pkbytes); if(encode(e, &certinfobytes) != ASN_OK) goto errret; -- 2.44.0