sslmake-openssl (old sslmake). sslmake-gnutls added (prefered).
This commit is contained in:
parent
2f50840e7e
commit
133fd96a7e
3 changed files with 84 additions and 0 deletions
60
sslmake-openssl
Executable file
60
sslmake-openssl
Executable file
|
@ -0,0 +1,60 @@
|
|||
#!/bin/sh
|
||||
# vi:set filetype=makefile
|
||||
NULL=0 exec make "CALL=$0" "EXE=`which $0`" -f "`which $0`" -- "$@"
|
||||
|
||||
EXE ?= sslmake
|
||||
CALL ?= `which $(EXE)`
|
||||
DEFAULTOPENSSLCNF ?= /etc/ssl/openssl.cnf
|
||||
S ?= .
|
||||
OPENSSL ?= /usr/bin/openssl
|
||||
GENRSA = $(OPENSSL) genrsa
|
||||
REQ = $(OPENSSL) req
|
||||
SIGN = $(OPENSSL) x509
|
||||
|
||||
all: help
|
||||
--help -h: help
|
||||
--renew -r: renew
|
||||
--build -b: build
|
||||
|
||||
help:
|
||||
@echo -e "\
|
||||
Creates SSL-keys and -certificate requests named %.key/%.csr (replace % by name)\n\
|
||||
--help -h: Display this help message.\n\
|
||||
--renew -r: Renews %.csr for all %.key.\n\
|
||||
--build -b: Builds %.csr and %.key for every %.cnf if doesn't exist.\n\
|
||||
%.cnf: Copies /etc/ssl/openssl.cnf to %.cnf.\n\
|
||||
%.key: Creates %.key.\n\
|
||||
%.csr: Creates %.csr and if doesn't exists %.key."
|
||||
|
||||
renew: $(patsubst %.key,%.csr.new,$(wildcard *.key))
|
||||
build: $(patsubst %.cnf,%csr,$(wildcard *.cnf))
|
||||
|
||||
root.key:
|
||||
@echo "root.crt keeper"
|
||||
root.crt:
|
||||
@echo "root.crt keeper"
|
||||
|
||||
%.del:
|
||||
[ ! -e "$(*)" ] || mv --backup=numbered "$(*)" "$(*).`date +%Y-%m-%d`"
|
||||
|
||||
%.new: %.del
|
||||
$(CALL) "$*"
|
||||
|
||||
%.cnf:
|
||||
cp "$(DEFAULTOPENSSLCNF)" "$(@)"
|
||||
|
||||
%.key:
|
||||
umask 177 ; $(GENRSA) -out "$(@)" 4096
|
||||
|
||||
%.csr: %.cnf %.key
|
||||
$(REQ) -config "$(*).cnf" -batch -nodes -new -key$$([ -e "$(*).key" ] || echo out ) "$(*).key" -out "$(@)"
|
||||
|
||||
%.crt: %.csr serial root.crt root.key
|
||||
$(SIGN) -req -days 365 -in "$(*).csr" -CA root.crt -CAkey root.key -CAserial "serial" -out "$(@)"
|
||||
|
||||
%.pem: %.crt %.key
|
||||
umask 177 ; cat $(^) > "$(@).bk"
|
||||
mv "$(@).bk" "$(@)"
|
||||
|
||||
.PHONY: all help build renew %.new %.del
|
||||
.PRECIOUS: %.csr %.key %.cnf %.pem
|
Loading…
Add table
Add a link
Reference in a new issue