summaryrefslogtreecommitdiffstats
path: root/src/seastar/tests/unit/mkcert.gmk
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
commit19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch)
tree42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/seastar/tests/unit/mkcert.gmk
parentInitial commit. (diff)
downloadceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.tar.xz
ceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.zip
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/seastar/tests/unit/mkcert.gmk')
-rw-r--r--src/seastar/tests/unit/mkcert.gmk94
1 files changed, 94 insertions, 0 deletions
diff --git a/src/seastar/tests/unit/mkcert.gmk b/src/seastar/tests/unit/mkcert.gmk
new file mode 100644
index 000000000..ecf2d5dfe
--- /dev/null
+++ b/src/seastar/tests/unit/mkcert.gmk
@@ -0,0 +1,94 @@
+server = $(shell hostname)
+domain = $(shell dnsdomainname)
+name = $(server)
+
+country = SE
+state = Stockholm
+locality= $(state)
+org = $(domain)
+unit = $(domain)
+mail = mx
+common = $(server).$(domain)
+email = postmaster@$(domain)
+ckey = ca$(key).pem
+
+pubkey = $(name).pub
+prvkey = $(name).key
+width = 4096
+
+csr = $(name).csr
+crt = $(name).crt
+
+root = ca$(name).pem
+rootkey = ca$(name).key
+
+config = $(name).cfg
+days = 3650
+
+alg = RSA
+alg_opt = -pkeyopt rsa_keygen_bits:$(width)
+
+hosts =
+
+all : $(crt)
+
+clean :
+ @rm -f $(crt) $(csr) $(pubkey) $(prvkey)
+
+%.key :
+ @echo generating $@
+ openssl genpkey -out $@ -algorithm $(alg) $(alg_opt)
+
+%.pub : %.key
+ @echo generating $@
+ openssl pkey -in $< -out $@
+
+$(config) : $(MAKEFILE_LIST)
+ @echo generating $@
+ @( \
+ echo [ req ] ; \
+ echo default_bits = $(width) ; \
+ echo default_keyfile = $(prvkey) ; \
+ echo default_md = sha256 ; \
+ echo distinguished_name = req_distinguished_name ; \
+ echo req_extensions = v3_req ; \
+ echo prompt = no ; \
+ echo [ req_distinguished_name ] ; \
+ echo C = $(country) ; \
+ echo ST = $(state) ; \
+ echo L = $(locality) ; \
+ echo O = $(org) ; \
+ echo OU = $(unit) ; \
+ echo CN= $(common) ; \
+ echo emailAddress = $(email) ; \
+ echo [v3_ca] ; \
+ echo subjectKeyIdentifier=hash ; \
+ echo authorityKeyIdentifier=keyid:always,issuer:always ; \
+ echo basicConstraints = CA:true ; \
+ echo [v3_req] ; \
+ echo "# Extensions to add to a certificate request" ; \
+ echo basicConstraints = CA:FALSE ; \
+ echo keyUsage = nonRepudiation, digitalSignature, keyEncipherment ; \
+ $(if $(hosts), echo subjectAltName = @alt_names ;) \
+ $(if $(hosts), echo [alt_names] ;) \
+ $(if $(hosts), index=1; for host in $(hosts); \
+ do echo DNS.$$index = $$host.$(domain); \
+ index=$$(($$index + 1));done ;) \
+ ) > $@
+
+%.csr : %.key $(config)
+ @echo generating $@
+ openssl req -new -key $< -out $@ -config $(config)
+
+%.crt : %.csr $(root) $(rootkey)
+ @echo generating $@
+ openssl x509 -req -in $< -CA $(root) -CAkey $(rootkey) -CAcreateserial \
+ -out $@ -days $(days)
+
+%.pem : %.key $(config)
+ @echo generating $@
+ openssl req -x509 -new -nodes -key $< -days $(days) -config $(config) \
+ -out $@
+
+.PRECIOUS : %.pem %.key %.pub %.crt %.csr
+