File: generate.client

package info (click to toggle)
taskd 1.1.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 1,576 kB
  • ctags: 1,141
  • sloc: cpp: 13,971; python: 1,523; sh: 1,080; perl: 610; ansic: 48; makefile: 21
file content (45 lines) | stat: -rwxr-xr-x 778 bytes parent folder | download | duplicates (3)
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
#!/bin/sh

# Take the correct binary to create the certificates
CERTTOOL=$(which gnutls-certtool || which certtool)
if [ -z "$CERTTOOL" ]
then
  echo "ERROR: No certtool found" >&2
  exit 1
fi

. ./vars

NAME=client
if [ $# -gt 0 ] ; then
  NAME=$1
fi

# Create a client key.
$CERTTOOL \
  --generate-privkey \
  --bits $BITS \
  --outfile ${NAME}.key.pem

# Sign a client cert with the key.
chmod 600 ${NAME}.key.pem
cat <<EOF >client.info
organization = $ORGANIZATION
cn = $CN
tls_www_client
encryption_key
signing_key
EOF

$CERTTOOL \
  --generate-certificate \
  --load-privkey ${NAME}.key.pem \
  --load-ca-certificate ca.cert.pem \
  --load-ca-privkey ca.key.pem \
  --template client.info \
  --outfile ${NAME}.cert.pem

chmod 600 ${NAME}.cert.pem
rm client.info
exit 0