From c66de4268e92746835b3d450e5ec30d5ee812562 Mon Sep 17 00:00:00 2001 From: thomkeh <7741417+thomkeh@users.noreply.github.com> Date: Tue, 17 Jul 2018 16:31:08 +0100 Subject: [PATCH] Correctly parse verify-x509 --- ovpn2onc.html | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/ovpn2onc.html b/ovpn2onc.html index bb6c8d8..1b22e54 100644 --- a/ovpn2onc.html +++ b/ovpn2onc.html @@ -251,12 +251,26 @@ params['TLSAuthContents'] = convertKey(keyString) if (authKey[1]) params['KeyDirection'] = authKey[1] } - // TODO: figure out what to do with this - // if (ovpn['verify-x509-name']) { - // params['VerifyX509'] = { - // 'Name': ovpn['verify-x509-name'] - // } - // } + if (ovpn['verify-x509-name']) { + const x509String = ovpn['verify-x509-name'] + let x509 = {} + if (x509String.includes("'")) { + // the name is quoted with ' + const parts = x509String.split("'") + x509['Name'] = `'${parts[1]}'` + if (parts[2]) { + x509['Type'] = parts[2].trim() + } + } else { + const parts = x509String.split(' ') + x509['Name'] = parts[0] + if (parts[1]) { + x509['Type'] = parts[1] + } + } + params['VerifyX509'] = x509 + } + // set parameters if they exist in the ovpn config let conditionalSet = (ovpnName, oncName, type = 'str') => { if (ovpn[ovpnName]) {