blob: 3c0a04d685fda597aa768f42f93a6299f09b182e [file] [log] [blame]
Zack Williamsba5c9d32022-06-05 21:49:18 -07001#!/usr/bin/env bash
2
3set -xeu -o pipefail
4
5VPN_USER=$1
6
7VPN_SITE=${VPN_SITE:-example}
8
9export IM_CA_NAME=openvpn_ca
10export LEAF_PURPOSE=client_cert_ext
11
12export LEAF_KEYPAIR=${VPN_USER}
13export LEAF_EMAIL=${LEAF_EMAIL:-"${VPN_USER}@opennetworking.org"}
14export LEAF_SAN="email:${LEAF_EMAIL}"
15
16make onf_pki/certout/${VPN_USER}.pem
17
18# build config
19VPN_CONFIG=openvpn/${VPN_USER}_${VPN_SITE}.ovpn
20cat openvpn/generic_${VPN_SITE}.ovpn > $VPN_CONFIG
21
22cat << EOKEY >> $VPN_CONFIG
23
24# client key
25<key>
26EOKEY
27
28# add key
29cat onf_pki/certout/${VPN_USER}.key >> $VPN_CONFIG
30
31cat << EOCERT >> $VPN_CONFIG
32</key>
33
34# client cert
35<cert>
36EOCERT
37
38# add pem
39cat onf_pki/certout/${VPN_USER}.pem >> $VPN_CONFIG
40
41cat << EOF >> $VPN_CONFIG
42</cert>
43EOF