-
Notifications
You must be signed in to change notification settings - Fork 0
/
revoke_endpoint.sh
executable file
·64 lines (52 loc) · 1.52 KB
/
revoke_endpoint.sh
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
#!/bin/sh
# Based on a template by BASH3 Boilerplate v2.3.0
# http://bash3boilerplate.sh/#authors
#
# The MIT License (MIT)
# Copyright (c) 2013 Kevin van Zonneveld and contributors
# You are not obligated to bundle the LICENSE file with your b3bp projects as long
# as you leave these references intact in the header comments of your source files.
# Exit on error. Append "|| true" if you expect an error.
set -o errexit
# Do not allow use of undefined vars. Use ${VAR:-} to use an undefined VAR
set -o nounset
BASE_DIR="$(cd "$(dirname "$0")" && pwd)"
CLIENT_DIR="${BASE_DIR}/clients"
SERVER_DIR="${BASE_DIR}/servers"
. "${BASE_DIR}/SETTINGS"
if [ $# -ne 2 ]; then
echo "This script revokes credentials for a VPN endpoint." >&2
echo "Usage: $0 <client|server> <common_name>" >&2
exit 1
fi
ENDPOINT_TYPE="$1"
ENDPOINT="$2"
if [ x"$ENDPOINT_TYPE" = x"client" ]; then
ENDPOINT_DIR="${CLIENT_DIR}/${ENDPOINT}"
OPENSSL_CONFIG="${BASE_DIR}/pki/openssl.cnf"
elif [ x"$ENDPOINT_TYPE" = x"server" ]; then
ENDPOINT_DIR="${SERVER_DIR}/${ENDPOINT}"
OPENSSL_CONFIG="${BASE_DIR}/pki/openssl-server.cnf"
else
echo "Endpoint type should be 'client' or 'server'!" >&2
exit 1
fi
if [ -d "$ENDPOINT_DIR" ]; then
:
else
echo "There doesn't seem to be a configuration for this endpoint." >&2
exit 1
fi
cd "${BASE_DIR}/pki"
if [ -e "ca/crlnumber" ]; then
:
else
echo 01 > ca/crlnumber
fi
openssl ca \
-config "${OPENSSL_CONFIG}" \
-revoke "${ENDPOINT_DIR}/openvpn.pem"
openssl ca \
-config "${OPENSSL_CONFIG}" \
-gencrl \
-out ca/crl/current.pem