File: gencert.sh

package info (click to toggle)
golang-github-containers-image 5.36.1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 5,152 kB
  • sloc: sh: 267; makefile: 100
file content (22 lines) | stat: -rwxr-xr-x 643 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/bash -e
config=$(mktemp -t)
if test -z "$config" ; then
	echo error creating temporary file for configuration
	exit 1
fi
trap 'rm -f "$config"' EXIT
cat > "$config" << EOF
[req]
prompt=no
distinguished_name=dn
x509_extensions=extensions
[extensions]
keyUsage=critical,digitalSignature,keyEncipherment,keyCertSign
extendedKeyUsage=serverAuth,clientAuth
basicConstraints=critical,CA:TRUE
subjectAltName=DNS:localhost,email:b@b.com
[dn]
O=Acme Co
EOF
serial=$(dd if=/dev/random bs=1 count=16 status=none | hexdump -e '"%x1"')
openssl req -new -set_serial 0x"$serial" -x509 -sha512 -days 3650 -key cert.key -config "$config" -out cert.cert