feat(rabbitmq): lab7 authenticate API and worker with client certificates
This commit is contained in:
Executable
+27
@@ -0,0 +1,27 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
cd "$(dirname "$0")/.."
|
||||
umask 077
|
||||
ca=certs/private/ingress
|
||||
dest=certs/private/broker-clients
|
||||
if [ -d "$dest" ]; then
|
||||
for role in api worker; do
|
||||
openssl verify -purpose sslclient -CAfile "$ca/ca.crt" "$dest/$role.crt"
|
||||
test -s "$dest/$role.key"
|
||||
test "$(openssl x509 -in "$dest/$role.crt" -noout -subject -nameopt RFC2253)" = "subject=CN=lab7-$role"
|
||||
test "$(openssl x509 -in "$dest/$role.crt" -pubkey -noout)" = "$(openssl pkey -in "$dest/$role.key" -pubout)"
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
tmp=$(mktemp -d certs/private/.broker-clients.XXXXXX)
|
||||
trap 'rm -rf "$tmp"' EXIT
|
||||
for role in api worker; do
|
||||
openssl req -new -newkey rsa:2048 -nodes -subj "/CN=lab7-$role" \
|
||||
-keyout "$tmp/$role.key" -out "$tmp/request"
|
||||
printf '%s\n' 'extendedKeyUsage=clientAuth' 'basicConstraints=critical,CA:FALSE' > "$tmp/ext"
|
||||
openssl x509 -req -days 30 -sha256 -in "$tmp/request" -CA "$ca/ca.crt" -CAkey "$ca/ca.key" \
|
||||
-set_serial "0x$(openssl rand -hex 16)" -extfile "$tmp/ext" -out "$tmp/$role.crt"
|
||||
done
|
||||
rm "$tmp/request" "$tmp/ext"
|
||||
chmod 0444 "$tmp"/*
|
||||
mv -T "$tmp" "$dest"
|
||||
Reference in New Issue
Block a user