CACN = MeineKleineCA

.PRECIOUS: %.key

%.crt: %.req %.cfg RootCA.key RootCA.crt
	openssl x509 -req -CA RootCA.crt -CAkey RootCA.key -extensions SAN -extfile "$*.cfg" -in "$*.req" -out "$@" -days 3

%.req: %.key
	openssl req -new -subj /CN="$*" -key "$<" -out "$@"

%.cfg:
	printf '[SAN]\nsubjectAltName=DNS:$*\n' >"$@"

RootCA.crt:	RootCA.key
	openssl req -x509 -days 14 -key "$<" -subj /CN="${CACN}" -out "$@"

%.key:
	openssl genrsa -out "$@"
