2012-04-13 12:47:30 +00:00
|
|
|
# inherited
|
|
|
|
VERSION?= unknown
|
|
|
|
OPENSSL?= openssl
|
|
|
|
MKDIR?= mkdir
|
|
|
|
|
|
|
|
# OpenSSL settings
|
2012-04-17 20:27:30 +00:00
|
|
|
CA_SUBJECT?= '/C=CH/O=SSLsplit Root CA/CN=SSLsplit Root CA/'
|
2012-04-13 12:47:30 +00:00
|
|
|
CA_DAYS?= 3650
|
2012-04-17 20:27:30 +00:00
|
|
|
CA_EXT:= v3_ca
|
|
|
|
CRT_SUBJECT?= '/C=CH/O=SSLsplit Test Certificate/CN=daniel.roe.ch/'
|
|
|
|
CRT_DAYS?= 365
|
|
|
|
CRT_EXT:= v3_crt
|
2012-04-13 12:47:30 +00:00
|
|
|
CONFIG:= x509v3ca.cnf
|
2012-04-30 20:48:19 +00:00
|
|
|
PASSWORD:= test
|
2015-03-24 19:31:38 +00:00
|
|
|
DIGEST:= -$(shell echo test | openssl dgst -sha256 2>/dev/null | grep -q f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2 && echo sha256 || echo sha1)
|
2012-04-13 12:47:30 +00:00
|
|
|
|
2012-04-30 20:48:19 +00:00
|
|
|
all: rsa dsa ec targets server pwd
|
2012-04-13 12:47:30 +00:00
|
|
|
|
2012-06-05 21:23:27 +00:00
|
|
|
testreqs: rsa targets server
|
|
|
|
|
2012-04-13 12:47:30 +00:00
|
|
|
session: session.pem
|
|
|
|
|
2012-10-02 22:50:50 +00:00
|
|
|
dh: dh512.param dh1024.param dh2048.param dh4096.param
|
2012-04-13 12:47:30 +00:00
|
|
|
|
|
|
|
rsa: rsa.pem
|
|
|
|
|
2012-04-30 20:48:19 +00:00
|
|
|
pwd: pwd.key
|
|
|
|
|
2012-04-13 12:47:30 +00:00
|
|
|
dsa: dsa.pem
|
|
|
|
|
|
|
|
ec: ec.pem
|
|
|
|
|
2012-04-17 20:27:30 +00:00
|
|
|
server: server.pem
|
|
|
|
|
2012-04-13 12:47:30 +00:00
|
|
|
dh512.param:
|
|
|
|
$(OPENSSL) dhparam -out $@ -2 512
|
|
|
|
|
|
|
|
dh1024.param:
|
|
|
|
$(OPENSSL) dhparam -out $@ -2 1024
|
|
|
|
|
|
|
|
dh2048.param:
|
|
|
|
$(OPENSSL) dhparam -out $@ -2 2048
|
|
|
|
|
2012-10-02 22:50:50 +00:00
|
|
|
dh4096.param:
|
|
|
|
$(OPENSSL) dhparam -out $@ -2 4096
|
|
|
|
|
2012-04-13 12:47:30 +00:00
|
|
|
dsa.param:
|
|
|
|
$(OPENSSL) dsaparam -out $@ 1024
|
|
|
|
|
|
|
|
dsa.key: dsa.param
|
|
|
|
$(OPENSSL) gendsa -out $@ $<
|
|
|
|
|
|
|
|
rsa.key:
|
|
|
|
$(OPENSSL) genrsa -out $@ 1024
|
|
|
|
|
2012-04-30 20:48:19 +00:00
|
|
|
pwd.key: rsa.key
|
|
|
|
echo $(PASSWORD) | $(OPENSSL) rsa -in $< -out $@ -aes128 -passout stdin
|
|
|
|
|
2012-04-13 12:47:30 +00:00
|
|
|
ec.key:
|
|
|
|
$(OPENSSL) ecparam -out $@ -name prime192v1 -genkey
|
|
|
|
|
2012-04-17 22:04:10 +00:00
|
|
|
%.crt: %.key $(CONFIG)
|
2015-03-24 19:31:38 +00:00
|
|
|
$(OPENSSL) req -new -nodes -x509 $(DIGEST) -out $@ -key $< \
|
2012-04-17 20:27:30 +00:00
|
|
|
-config $(CONFIG) -extensions $(CA_EXT) \
|
2012-04-13 12:47:30 +00:00
|
|
|
-subj $(CA_SUBJECT) \
|
|
|
|
-set_serial 0 -days $(CA_DAYS)
|
|
|
|
|
2012-04-17 20:27:30 +00:00
|
|
|
server.key:
|
|
|
|
$(OPENSSL) genrsa -out $@ 1024
|
|
|
|
|
2012-04-17 22:04:10 +00:00
|
|
|
server.crt: server.key $(CONFIG)
|
2015-03-24 19:31:38 +00:00
|
|
|
$(OPENSSL) req -new -nodes -x509 $(DIGEST) -out $@ -key $< \
|
2012-04-17 20:27:30 +00:00
|
|
|
-config $(CONFIG) -extensions $(CRT_EXT) \
|
|
|
|
-subj $(CRT_SUBJECT) \
|
|
|
|
-set_serial 42 -days $(CRT_DAYS)
|
|
|
|
|
2012-04-13 12:47:30 +00:00
|
|
|
%.pem: %.crt %.key
|
|
|
|
cat $^ >$@
|
|
|
|
|
2014-01-29 20:20:16 +00:00
|
|
|
targets: targets/daniel.roe.ch.pem targets/wildcard.roe.ch.pem
|
2014-01-29 20:25:19 +00:00
|
|
|
$(RM) rsa.srl
|
2014-01-29 20:20:16 +00:00
|
|
|
|
|
|
|
targets/daniel.roe.ch.pem: rsa.crt
|
2012-04-17 22:04:10 +00:00
|
|
|
$(MKDIR) -p targets
|
2012-04-13 12:47:30 +00:00
|
|
|
$(OPENSSL) genrsa -out targets/daniel.roe.ch.key 1024
|
2015-03-24 19:31:38 +00:00
|
|
|
$(OPENSSL) req -new $(DIGEST) -subj '/C=CH/CN=daniel.roe.ch/' \
|
2012-04-13 12:47:30 +00:00
|
|
|
-key targets/daniel.roe.ch.key \
|
|
|
|
-out targets/daniel.roe.ch.csr
|
2015-03-24 19:31:38 +00:00
|
|
|
$(OPENSSL) x509 -req $(DIGEST) -CAcreateserial -days 365 \
|
2012-04-13 12:47:30 +00:00
|
|
|
-CA rsa.crt -CAkey rsa.key \
|
|
|
|
-in targets/daniel.roe.ch.csr \
|
|
|
|
-out targets/daniel.roe.ch.crt
|
|
|
|
cat targets/daniel.roe.ch.crt targets/daniel.roe.ch.key rsa.crt \
|
|
|
|
>targets/daniel.roe.ch.pem
|
2014-01-29 20:25:19 +00:00
|
|
|
$(RM) targets/daniel.roe.ch.key targets/daniel.roe.ch.csr \
|
|
|
|
targets/daniel.roe.ch.crt
|
2014-01-29 20:20:16 +00:00
|
|
|
|
|
|
|
targets/wildcard.roe.ch.pem: rsa.crt
|
|
|
|
$(MKDIR) -p targets
|
2012-04-13 12:47:30 +00:00
|
|
|
$(OPENSSL) genrsa -out targets/wildcard.roe.ch.key 1024
|
2015-03-24 19:31:38 +00:00
|
|
|
$(OPENSSL) req -new $(DIGEST) -subj '/C=CH/CN=*.roe.ch/' \
|
2012-04-13 12:47:30 +00:00
|
|
|
-key targets/wildcard.roe.ch.key \
|
|
|
|
-out targets/wildcard.roe.ch.csr
|
2015-03-24 19:31:38 +00:00
|
|
|
$(OPENSSL) x509 -req $(DIGEST) -CAcreateserial -days 365 \
|
2012-04-13 12:47:30 +00:00
|
|
|
-CA rsa.crt -CAkey rsa.key \
|
|
|
|
-in targets/wildcard.roe.ch.csr \
|
|
|
|
-out targets/wildcard.roe.ch.crt
|
|
|
|
cat targets/wildcard.roe.ch.crt targets/wildcard.roe.ch.key rsa.crt \
|
|
|
|
>targets/wildcard.roe.ch.pem
|
2014-01-29 20:25:19 +00:00
|
|
|
$(RM) targets/wildcard.roe.ch.key targets/wildcard.roe.ch.csr \
|
|
|
|
targets/wildcard.roe.ch.crt
|
2012-04-13 12:47:30 +00:00
|
|
|
|
2014-01-11 20:49:05 +00:00
|
|
|
# localhost network connectivity is required
|
2012-04-13 12:47:30 +00:00
|
|
|
session.pem:
|
2014-01-14 16:37:17 +00:00
|
|
|
openssl s_server -accept 46143 -cert server.pem -quiet -no_ssl2 & \
|
2014-01-11 20:49:05 +00:00
|
|
|
pid=$$! ; \
|
|
|
|
sleep 1 ; \
|
2014-01-14 16:37:17 +00:00
|
|
|
echo q | $(OPENSSL) s_client -connect localhost:46143 \
|
|
|
|
-quiet -no_ign_eof -sess_out $@ ; \
|
2014-01-11 20:49:05 +00:00
|
|
|
kill $$pid
|
2012-04-13 12:47:30 +00:00
|
|
|
test -r $@
|
|
|
|
|
|
|
|
clean:
|
2012-04-17 20:27:30 +00:00
|
|
|
rm -rf rsa.* dsa.* ec.* dh*.param targets *.srl session.pem server.*
|
2012-04-13 12:47:30 +00:00
|
|
|
|
2014-01-29 20:14:39 +00:00
|
|
|
.PHONY: all clean rsa dsa ec dh session targets
|
2012-04-13 12:47:30 +00:00
|
|
|
|