1 UTF8 := $(shell locale -c LC_CTYPE -k | grep -q charmap.*UTF-8 && echo -utf8)
5 .SUFFIXES: .key .csr .crt .pem
6 .PRECIOUS: %.key %.csr %.crt %.pem
9 @echo "This makefile allows you to create:"
10 @echo " o public/private key pairs"
11 @echo " o SSL certificate signing requests (CSRs)"
12 @echo " o self-signed SSL test certificates"
14 @echo "To create a key pair, run \"make SOMETHING.key\"."
15 @echo "To create a CSR, run \"make SOMETHING.csr\"."
16 @echo "To create a test certificate, run \"make SOMETHING.crt\"."
17 @echo "To create a key and a test certificate in one file, run \"make SOMETHING.pem\"."
19 @echo "To create a key for use with Apache, run \"make genkey\"."
20 @echo "To create a CSR for use with Apache, run \"make certreq\"."
21 @echo "To create a test certificate for use with Apache, run \"make testcert\"."
23 @echo "To create a test certificate with serial number other than zero, add SERIAL=num"
26 @echo " make server.key"
27 @echo " make server.csr"
28 @echo " make server.crt"
29 @echo " make stunnel.pem"
32 @echo " make testcert"
33 @echo " make server.crt SERIAL=1"
34 @echo " make stunnel.pem SERIAL=2"
35 @echo " make testcert SERIAL=3"
39 PEM1=`/bin/mktemp /tmp/openssl.XXXXXX` ; \
40 PEM2=`/bin/mktemp /tmp/openssl.XXXXXX` ; \
41 /usr/bin/openssl req $(UTF8) -newkey rsa:1024 -keyout $$PEM1 -nodes -x509 -days 365 -out $$PEM2 -set_serial $(SERIAL) ; \
49 /usr/bin/openssl genrsa -des3 1024 > $@
53 /usr/bin/openssl req $(UTF8) -new -key $^ -out $@
57 /usr/bin/openssl req $(UTF8) -new -key $^ -x509 -days 365 -out $@ -set_serial $(SERIAL)
60 KEY=$(TLSROOT)/private/localhost.key
61 CSR=$(TLSROOT)/certs/localhost.csr
62 CRT=$(TLSROOT)/certs/localhost.crt
70 /usr/bin/openssl req $(UTF8) -new -key $(KEY) -out $(CSR)
74 /usr/bin/openssl req $(UTF8) -new -key $(KEY) -x509 -days 365 -out $(CRT) -set_serial $(SERIAL)