about summary refs log tree commit diff stats
path: root/tests/by-name/em/email-dns/nodes/acme/certs/generate
blob: 0d6258eb2195b0083eebb398871587473488108a (plain) (blame)
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
59
60
61
62
63
64
65
66
#! /usr/bin/env nix-shell
#! nix-shell -p gnutls -p dash -i dash --impure
# shellcheck shell=dash

# For development and testing.
# Create a CA key and cert, and use that to generate a server key and cert.
# Creates:
#   ca.key.pem
#   ca.cert.pem
#   server.key.pem
#   server.cert.pem

export SEC_PARAM=ultra
export EXPIRATION_DAYS=123456
export ORGANIZATION="Vhack.eu Test Keys"
export COUNTRY=EU
export SAN="acme.test"
export KEY_TYPE="ed25519"

BASEDIR="$(dirname "$0")"
GENERATION_LOCATION="$BASEDIR/output"
cd "$BASEDIR" || {
    echo "(BUG?) No basedir ('$BASEDIR')" 1>&2
    exit 1
}

ca=false
clients=false

usage() {
    echo "Usage: $0 --ca|--clients"
    exit 2
}

if [ "$#" -eq 0 ]; then
    usage
fi

for arg in "$@"; do
    case "$arg" in
    "--ca")
        ca=true
        ;;
    "--clients")
        clients=true
        ;;
    *)
        usage
        ;;
    esac
done

[ -d "$GENERATION_LOCATION" ] || mkdir --parents "$GENERATION_LOCATION"
cd "$GENERATION_LOCATION" || echo "(BUG?) No generation location fould!" 1>&2

[ "$ca" = true ] && ../generate.ca

# Creates:
#   <client_name>.key.pem
#   <client_name>.cert.pem
#
[ "$clients" = true ] && ../generate.client "acme.test"

echo "(INFO) Look for the keys at: $GENERATION_LOCATION"

# vim: ft=sh