From 12e1f5501a4074f0afda70b8dc47ee9ac60f5192 Mon Sep 17 00:00:00 2001 From: thomkeh <7741417+thomkeh@users.noreply.github.com> Date: Tue, 17 Jul 2018 15:41:28 +0100 Subject: [PATCH] Use the correct format for the client certificates They're usually not in the PKCS#12 format but in X509. --- ovpn2onc.html | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/ovpn2onc.html b/ovpn2onc.html index 8e22358..61c41f1 100644 --- a/ovpn2onc.html +++ b/ovpn2onc.html @@ -220,11 +220,13 @@ let [cas, caGuids] = createCerts(keys, ovpn['ca'], 'Authority') params['ServerCARefs'] = caGuids certs = certs.concat(cas) - let [clientCerts, clientCertGuids] = createCerts(keys, ovpn['cert'], 'Client') - if (clientCerts[0]) { - params['ClientCertType'] = 'Ref' - params['ClientCertRef'] = clientCertGuids[0] - certs.push(clientCerts[0]) + let [clientCerts, clientCertGuids] = createCerts(keys, ovpn['cert'], 'Authority') + if (clientCerts) { + params['ClientCertType'] = 'Pattern' + params['ClientCertPattern'] = { + 'IssuerCARef': clientCertGuids + } + certs = certs.concat(clientCerts) } else { params['ClientCertType'] = 'None' } @@ -344,14 +346,16 @@ alert("Please provide the file '" + certName + "' in 'Certificates and keys'") } let rawCerts = extractCas(cert) + const format = (certType === 'Authority') ? 'X509' : 'PKCS12' for (const cert of rawCerts) { const guid = `{${uuidv4()}}` certGuids.push(guid) - certs.push({ + let oncCert = { 'GUID': guid, - 'Type': certType, - 'X509': cert - }) + 'Type': certType + } + oncCert[format] = cert + certs.push(oncCert) } } return [certs, certGuids]