-
Notifications
You must be signed in to change notification settings - Fork 0
/
cert-metadata.sh.j2
44 lines (37 loc) · 1.39 KB
/
cert-metadata.sh.j2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
# Common configuration for all certificates
# Edit these fields to be appropriate for your organization
# If they are left blank, they will not be included. Do not leave COUNTRY
# blank (you may set it to "XX" if you want to be obtuse).
#
# Values for each may be optionally set as environment variables.
# Replace variables such as ${STATE} and ${CITY} as needed.
#
COUNTRY={{ country | default('US') }}
STATE={{ state | default('XX') }}
CITY={{ city | default('XX') }}
ORGANIZATION={{ organization | default('EmeraldSpec') }}
ORGANIZATIONAL_UNIT={{ organizational_unit | default('tak') }}
CAPASS=${CAPASS:-{{ capass | default('atakatak') }}}
PASS=${PASS:-$CAPASS}
## subdirectory to put all the actual certs and keys in
DIR=files
##### don't edit below this line #####
if [[ -z ${STATE} || -z ${CITY} || -z ${ORGANIZATIONAL_UNIT} ]]; then
echo "Please set the following variables before running this script: STATE, CITY, ORGANIZATIONAL_UNIT. \n
The following environment variables can also be set to further secure and customize your certificates: ORGANIZATION, ORGANIZATIONAL_UNIT, CAPASS, and PASS."
exit -1
fi
SUBJBASE="/C=${COUNTRY}/"
if [ -n "$STATE" ]; then
SUBJBASE+="ST=${STATE}/"
fi
if [ -n "$CITY" ]; then
SUBJBASE+="L=${CITY}/"
fi
if [ -n "$ORGANIZATION" ]; then
SUBJBASE+="O=${ORGANIZATION}/"
fi
if [ -n "$ORGANIZATIONAL_UNIT" ]; then
SUBJBASE+="OU=${ORGANIZATIONAL_UNIT}/"
fi