-
Notifications
You must be signed in to change notification settings - Fork 5
/
selfsigned-keypair
executable file
·58 lines (47 loc) · 1.15 KB
/
selfsigned-keypair
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
#
# Generate a self-signed keypair, independent of the generated CA.
for SCRIPT in common/*.sh; do
source ${SCRIPT}
done
NAME=""
LIFETIME=""
FAIL="false"
while getopts ":n:l:" VARNAME; do
case ${VARNAME} in
n)
NAME="${OPTARG}"
;;
l)
LIFETIME="${OPTARG}"
;;
\?)
error "Unrecognized option: -${OPTARG}"
FAIL="true"
;;
:)
error "Option -${OPTARG} requires an argument."
FAIL="true"
;;
esac
done
[ -z "${NAME}" ] && {
error "Missing required parameter: -n"
FAIL="true"
}
# Default to 365 days.
[ -z "${LIFETIME}" ] && LIFETIME="365"
if [ "${FAIL}" = "true" ]; then
cat <<EOM
Usage: docker run [..] cloudpipe/keymaster selfsigned-keypair -n NAME [-l LIFETIME]
Generate a public certificate and private key that are self-signed and unrelated to any other
credentials you've created.
(Required)
-n NAME Specify the name of the generated keypair. This is used for the filenames.
(Optional)
-l LIFETIME Specify the duration for which this certificate should be valid, in days. Defaults to
365.
EOM
exit 1
fi
generate_selfsigned "${NAME}" "${LIFETIME}"