Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameterize certificate generation script #67

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ RAW_ROOT_TARGET=root
ROOT_TARGET=$(RAW_ROOT_TARGET)/usr/bin
BIN_TARGET=$(ROOT_TARGET)/$(BIN)
VERSION?=0.0.1
SUB_ALT_NAME?="tang-iam-proxy-passthrough"

.PHONY: all bin cert img clean test

all: bin cert img
echo "Building all ..."

cert:
./generate-signed-certificate.sh
./generate-signed-certificate.sh -s $(SUB_ALT_NAME)
mkdir -p $(ROOT_TARGET)
cp server_bundle.pem server.key $(ROOT_TARGET)

Expand Down
39 changes: 35 additions & 4 deletions generate-signed-certificate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,42 @@
# limitations under the License.
#
certname="server"
test -n "$1" && certname="$1"
sub_alt_name="tang-backend-tang"

printf "*************************\n"
printf "certname:%s\n" "${certname}"
printf "*************************\n"
function usage() {
echo
echo "$1 [-n name] [-s subAlternateName][-h] [-v]"
echo
echo "Examples:"
echo " $1 -n server -s tang-iam-proxy-passthrough"
echo
echo "Options:"
echo " -n \"name\": Base name for generated files"
echo " -s \"subAlternateName\": extra Subject Alternate Name for server certificate"
echo " -h: help"
echo
exit "$2"
}

while getopts "n:s:h" arg
do
case "${arg}" in
n) certname=${OPTARG}
;;

s) sub_alt_name=${OPTARG}
;;
h) usage "$0" 0
;;
*) usage "$0" 1
;;
esac
done

printf "*****************************************\n"
printf "certname:%s\n" "${certname}"
printf "sub_alternate_name:%s\n" "${sub_alt_name}"
printf "*****************************************\n"

############################# Generate CA ###############################
openssl genrsa -out "ca_${certname}.key" 4096
Expand All @@ -42,6 +72,7 @@ subjectAltName = @alt_names
IP.1 = 1.2.3.4
DNS.1 = fedora
DNS.2 = localhost
DNS.3 = ${sub_alt_name}
EOF

openssl genrsa -out "${certname}.key" 4096
Expand Down