Skip to content

Commit 0f51b56

Browse files
author
Tom Maher
committed
add script to generate fixture
1 parent 3c18b1e commit 0f51b56

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

script/generate-fixture-ca

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
3+
BASE_PATH=$( cd "`dirname $0`/../test/fixtures/ca" && pwd )
4+
cd "${BASE_PATH}" || exit 4
5+
6+
USAGE=$( cat << EOS
7+
Usage:
8+
$0 --regenerate
9+
10+
Generates a new self-signed CA, for integration testing. This should only need
11+
to be run if you are writing new TLS/SSL tests, and need to generate
12+
additional fixtuer CAs.
13+
14+
This script uses the GnuTLS certtool CLI. If you are on macOS,
15+
'brew install gnutls', and it will be installed as 'gnutls-certtool'.
16+
Apple unfortunately ships with an incompatible /usr/bin/certtool that does
17+
different things.
18+
EOS
19+
)
20+
21+
if [ "x$1" != 'x--regenerate' ]; then
22+
echo "${USAGE}"
23+
exit 1
24+
fi
25+
26+
TOOL=`type -p certtool`
27+
if [ "$(uname)" = "Darwin" ]; then
28+
TOOL=`type -p gnutls-certtool`
29+
if [ ! -x "${TOOL}" ]; then
30+
echo "Sorry, Darwin requires gnutls-certtool; try `brew install gnutls`"
31+
exit 2
32+
fi
33+
fi
34+
35+
if [ ! -x "${TOOL}" ]; then
36+
echo "Sorry, no certtool found!"
37+
exit 3
38+
fi
39+
export TOOL
40+
41+
42+
${TOOL} --generate-privkey > ./cakey.pem
43+
${TOOL} --generate-self-signed \
44+
--load-privkey ./cakey.pem \
45+
--template ./ca.info \
46+
--outfile ./cacert.pem
47+
48+
echo "cert and private key generated! Don't forget to check them in"

0 commit comments

Comments
 (0)