forked from cloudfoundry/diego-release
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate-bbs-certs
executable file
·49 lines (39 loc) · 1.5 KB
/
generate-bbs-certs
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
#!/bin/sh
set -e -x
function usage() {
>&2 echo " Usage:
$0 DIEGO_CA_NAME DIEGO_CA_CERT_DIRECTORY
Ex:
$0 diegoCA ~/workspace/diego-release/diego-certs/
"
exit 1
}
ca_name=$1
ca_cert_directory=$2
if [ -z "${ca_name}" ]; then
>&2 echo "Specify a CA"
usage
fi
if [ ! -d "${ca_cert_directory}" ]; then
>&2 echo "Specify location of CA cert and key"
usage
fi
# Install certstrap
go get -v github.com/square/certstrap
# Place keys and certificates here
output_path="diego-certs/bbs-certs"
mkdir -p ${output_path}
# Server certificate to share across the bbs cluster
server_cn=bbs.service.cf.internal
server_domain='*.bbs.service.cf.internal,bbs.service.cf.internal'
certstrap --depot-path ${ca_cert_directory} request-cert --passphrase '' --common-name $server_cn --domain $server_domain
certstrap --depot-path ${ca_cert_directory} sign $server_cn --CA $ca_name
mv -f ${ca_cert_directory}/$server_cn.key ${output_path}/server.key
mv -f ${ca_cert_directory}/$server_cn.csr ${output_path}/server.csr
mv -f ${ca_cert_directory}/$server_cn.crt ${output_path}/server.crt
# Client certificate to distribute to jobs that access bbs
certstrap --depot-path ${ca_cert_directory} request-cert --passphrase '' --common-name 'bbs client'
certstrap --depot-path ${ca_cert_directory} sign bbs_client --CA $ca_name
mv -f ${ca_cert_directory}/bbs_client.key ${output_path}/client.key
mv -f ${ca_cert_directory}/bbs_client.csr ${output_path}/client.csr
mv -f ${ca_cert_directory}/bbs_client.crt ${output_path}/client.crt