2016-01-15 16:48:27 +08:00
|
|
|
#! /bin/bash
|
|
|
|
#
|
2023-09-07 16:59:15 +08:00
|
|
|
# Copyright 2016-2023 The OpenSSL Project Authors. All Rights Reserved.
|
2016-01-15 16:48:27 +08:00
|
|
|
# Copyright (c) 2016 Viktor Dukhovni <openssl-users@dukhovni.org>.
|
|
|
|
# All rights reserved.
|
|
|
|
#
|
2018-12-06 20:05:25 +08:00
|
|
|
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
2017-06-16 00:03:40 +08:00
|
|
|
# this file except in compliance with the License. You can obtain a copy
|
|
|
|
# in the file LICENSE in the source distribution or at
|
|
|
|
# https://www.openssl.org/source/license.html
|
|
|
|
|
|
|
|
# This file is dual-licensed and is also available under other terms.
|
|
|
|
# Please contact the author.
|
2016-01-15 16:48:27 +08:00
|
|
|
|
|
|
|
# 100 years should be enough for now
|
2016-06-23 01:09:42 +08:00
|
|
|
if [ -z "$DAYS" ]; then
|
|
|
|
DAYS=36525
|
|
|
|
fi
|
2016-01-15 16:48:27 +08:00
|
|
|
|
2016-03-19 10:09:41 +08:00
|
|
|
if [ -z "$OPENSSL_SIGALG" ]; then
|
|
|
|
OPENSSL_SIGALG=sha256
|
|
|
|
fi
|
|
|
|
|
2016-06-22 20:36:08 +08:00
|
|
|
if [ -z "$REQMASK" ]; then
|
|
|
|
REQMASK=utf8only
|
|
|
|
fi
|
|
|
|
|
2016-01-15 16:48:27 +08:00
|
|
|
stderr_onerror() {
|
|
|
|
(
|
|
|
|
err=$("$@" >&3 2>&1) || {
|
|
|
|
printf "%s\n" "$err" >&2
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
) 3>&1
|
|
|
|
}
|
|
|
|
|
|
|
|
key() {
|
|
|
|
local key=$1; shift
|
|
|
|
|
|
|
|
local alg=rsa
|
|
|
|
if [ -n "$OPENSSL_KEYALG" ]; then
|
|
|
|
alg=$OPENSSL_KEYALG
|
|
|
|
fi
|
|
|
|
|
|
|
|
local bits=2048
|
|
|
|
if [ -n "$OPENSSL_KEYBITS" ]; then
|
|
|
|
bits=$OPENSSL_KEYBITS
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -f "${key}.pem" ]; then
|
|
|
|
args=(-algorithm "$alg")
|
|
|
|
case $alg in
|
|
|
|
rsa) args=("${args[@]}" -pkeyopt rsa_keygen_bits:$bits );;
|
Suppress DANE TLSA reflection when verification fails
As documented both SSL_get0_dane_authority() and SSL_get0_dane_tlsa()
are expected to return a negative match depth and nothing else when
verification fails. However, this only happened when verification
failed during chain construction. Errors in verification of the
constructed chain did not have the intended effect on these functions.
This commit updates the functions to check for verify_result ==
X509_V_OK, and no longer erases any accumulated match information
when chain construction fails. Sophisticated developers can, with
care, use SSL_set_verify_result(ssl, X509_V_OK) to "peek" at TLSA
info even when verification fail. They must of course first check
and save the real error, and restore the original error as quickly
as possible. Hiding by default seems to be the safer interface.
Introduced X509_V_ERR_DANE_NO_MATCH code to signal failure to find
matching TLSA records. Previously reported via X509_V_ERR_CERT_UNTRUSTED.
This also changes the "-brief" output from s_client to include
verification results and TLSA match information.
Mentioned session resumption in code example in SSL_CTX_dane_enable(3).
Also mentioned that depths returned are relative to the verified chain
which is now available via SSL_get0_verified_chain(3).
Added a few more test-cases to danetest, that exercise the new
code.
Resolved thread safety issue in use of static buffer in
X509_verify_cert_error_string().
Fixed long-stating issue in apps/s_cb.c which always sets verify_error
to either X509_V_OK or "chain to long", code elsewhere (e.g.
s_time.c), seems to expect the actual error. [ The new chain
construction code is expected to correctly generate "chain
too long" errors, so at some point we need to drop the
work-arounds, once SSL_set_verify_depth() is also fixed to
propagate the depth to X509_STORE_CTX reliably. ]
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-02-08 08:07:57 +08:00
|
|
|
ec) args=("${args[@]}" -pkeyopt "ec_paramgen_curve:$bits")
|
2016-01-15 16:48:27 +08:00
|
|
|
args=("${args[@]}" -pkeyopt ec_param_enc:named_curve);;
|
2017-02-17 22:44:59 +08:00
|
|
|
dsa) args=(-paramfile "$bits");;
|
2017-06-14 23:37:06 +08:00
|
|
|
ed25519) ;;
|
2018-02-27 21:02:00 +08:00
|
|
|
ed448) ;;
|
2016-01-15 16:48:27 +08:00
|
|
|
*) printf "Unsupported key algorithm: %s\n" "$alg" >&2; return 1;;
|
|
|
|
esac
|
|
|
|
stderr_onerror \
|
|
|
|
openssl genpkey "${args[@]}" -out "${key}.pem"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2016-06-19 16:56:09 +08:00
|
|
|
# Usage: $0 req keyname dn1 dn2 ...
|
2016-01-15 16:48:27 +08:00
|
|
|
req() {
|
|
|
|
local key=$1; shift
|
|
|
|
|
|
|
|
key "$key"
|
|
|
|
local errs
|
|
|
|
|
|
|
|
stderr_onerror \
|
2016-03-19 10:09:41 +08:00
|
|
|
openssl req -new -"${OPENSSL_SIGALG}" -key "${key}.pem" \
|
2016-06-22 20:36:08 +08:00
|
|
|
-config <(printf "string_mask=%s\n[req]\n%s\n%s\n[dn]\n" \
|
|
|
|
"$REQMASK" "prompt = no" "distinguished_name = dn"
|
2016-06-19 16:56:09 +08:00
|
|
|
for dn in "$@"; do echo "$dn"; done)
|
2016-01-15 16:48:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
req_nocn() {
|
|
|
|
local key=$1; shift
|
|
|
|
|
|
|
|
key "$key"
|
|
|
|
stderr_onerror \
|
2016-03-19 10:09:41 +08:00
|
|
|
openssl req -new -"${OPENSSL_SIGALG}" -subj / -key "${key}.pem" \
|
2016-01-15 16:48:27 +08:00
|
|
|
-config <(printf "[req]\n%s\n[dn]\nCN_default =\n" \
|
|
|
|
"distinguished_name = dn")
|
|
|
|
}
|
|
|
|
|
|
|
|
cert() {
|
|
|
|
local cert=$1; shift
|
|
|
|
local exts=$1; shift
|
|
|
|
|
|
|
|
stderr_onerror \
|
2016-03-19 10:09:41 +08:00
|
|
|
openssl x509 -req -"${OPENSSL_SIGALG}" -out "${cert}.pem" \
|
2016-01-15 16:48:27 +08:00
|
|
|
-extfile <(printf "%s\n" "$exts") "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
genroot() {
|
|
|
|
local cn=$1; shift
|
|
|
|
local key=$1; shift
|
|
|
|
local cert=$1; shift
|
2020-12-13 04:36:06 +08:00
|
|
|
local bcon="basicConstraints = critical,CA:true"
|
|
|
|
local ku="keyUsage = keyCertSign,cRLSign"
|
2016-01-15 16:48:27 +08:00
|
|
|
local skid="subjectKeyIdentifier = hash"
|
|
|
|
local akid="authorityKeyIdentifier = keyid"
|
|
|
|
|
2020-12-13 04:36:06 +08:00
|
|
|
exts=$(printf "%s\n%s\n%s\n" "$bcon" "$ku" "$skid" "$akid")
|
2016-01-29 15:28:43 +08:00
|
|
|
for eku in "$@"
|
|
|
|
do
|
|
|
|
exts=$(printf "%s\nextendedKeyUsage = %s\n" "$exts" "$eku")
|
|
|
|
done
|
2016-06-19 16:56:09 +08:00
|
|
|
csr=$(req "$key" "CN = $cn") || return 1
|
2016-01-15 16:48:27 +08:00
|
|
|
echo "$csr" |
|
|
|
|
cert "$cert" "$exts" -signkey "${key}.pem" -set_serial 1 -days "${DAYS}"
|
|
|
|
}
|
|
|
|
|
|
|
|
genca() {
|
2021-01-26 18:53:15 +08:00
|
|
|
local OPTIND=1
|
|
|
|
local purpose=
|
|
|
|
|
2023-03-07 23:22:40 +08:00
|
|
|
while getopts p:c: o
|
2021-01-26 18:53:15 +08:00
|
|
|
do
|
|
|
|
case $o in
|
|
|
|
p) purpose="$OPTARG";;
|
2023-03-07 23:22:40 +08:00
|
|
|
c) certpol="$OPTARG";;
|
|
|
|
*) echo "Usage: $0 genca [-p EKU][-c policyoid] cn keyname certname cakeyname cacertname" >&2
|
2021-01-26 18:53:15 +08:00
|
|
|
return 1;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
shift $((OPTIND - 1))
|
2016-01-15 16:48:27 +08:00
|
|
|
local cn=$1; shift
|
|
|
|
local key=$1; shift
|
|
|
|
local cert=$1; shift
|
|
|
|
local cakey=$1; shift
|
|
|
|
local cacert=$1; shift
|
2020-12-13 04:36:06 +08:00
|
|
|
local bcon="basicConstraints = critical,CA:true"
|
|
|
|
local ku="keyUsage = keyCertSign,cRLSign"
|
2016-01-15 16:48:27 +08:00
|
|
|
local skid="subjectKeyIdentifier = hash"
|
|
|
|
local akid="authorityKeyIdentifier = keyid"
|
|
|
|
|
2020-12-13 04:36:06 +08:00
|
|
|
exts=$(printf "%s\n%s\n%s\n" "$bcon" "$ku" "$skid" "$akid")
|
2021-01-26 18:53:15 +08:00
|
|
|
if [ -n "$purpose" ]; then
|
|
|
|
exts=$(printf "%s\nextendedKeyUsage = %s\n" "$exts" "$purpose")
|
|
|
|
fi
|
2016-06-22 20:36:08 +08:00
|
|
|
if [ -n "$NC" ]; then
|
|
|
|
exts=$(printf "%s\nnameConstraints = %s\n" "$exts" "$NC")
|
|
|
|
fi
|
2023-03-07 23:22:40 +08:00
|
|
|
if [ -n "$certpol" ]; then
|
|
|
|
exts=$(printf "%s\ncertificatePolicies = %s\n" "$exts" "$certpol")
|
|
|
|
fi
|
|
|
|
|
2016-06-19 16:56:09 +08:00
|
|
|
csr=$(req "$key" "CN = $cn") || return 1
|
2016-01-15 16:48:27 +08:00
|
|
|
echo "$csr" |
|
|
|
|
cert "$cert" "$exts" -CA "${cacert}.pem" -CAkey "${cakey}.pem" \
|
2021-01-26 18:53:15 +08:00
|
|
|
-set_serial 2 -days "${DAYS}" "$@"
|
2016-01-15 16:48:27 +08:00
|
|
|
}
|
|
|
|
|
2016-03-30 07:40:03 +08:00
|
|
|
gen_nonbc_ca() {
|
|
|
|
local cn=$1; shift
|
|
|
|
local key=$1; shift
|
|
|
|
local cert=$1; shift
|
|
|
|
local cakey=$1; shift
|
|
|
|
local cacert=$1; shift
|
|
|
|
local skid="subjectKeyIdentifier = hash"
|
|
|
|
local akid="authorityKeyIdentifier = keyid"
|
|
|
|
|
|
|
|
exts=$(printf "%s\n%s\n%s\n" "$skid" "$akid")
|
|
|
|
exts=$(printf "%s\nkeyUsage = %s\n" "$exts" "keyCertSign, cRLSign")
|
|
|
|
for eku in "$@"
|
|
|
|
do
|
|
|
|
exts=$(printf "%s\nextendedKeyUsage = %s\n" "$exts" "$eku")
|
|
|
|
done
|
2016-06-19 16:56:09 +08:00
|
|
|
csr=$(req "$key" "CN = $cn") || return 1
|
2016-03-30 07:40:03 +08:00
|
|
|
echo "$csr" |
|
|
|
|
cert "$cert" "$exts" -CA "${cacert}.pem" -CAkey "${cakey}.pem" \
|
|
|
|
-set_serial 2 -days "${DAYS}"
|
|
|
|
}
|
|
|
|
|
2016-06-19 16:56:09 +08:00
|
|
|
# Usage: $0 genpc keyname certname eekeyname eecertname pcext1 pcext2 ...
|
|
|
|
#
|
|
|
|
# Note: takes csr on stdin, so must be used with $0 req like this:
|
|
|
|
#
|
|
|
|
# $0 req keyname dn | $0 genpc keyname certname eekeyname eecertname pcext ...
|
|
|
|
genpc() {
|
|
|
|
local key=$1; shift
|
|
|
|
local cert=$1; shift
|
|
|
|
local cakey=$1; shift
|
|
|
|
local ca=$1; shift
|
|
|
|
|
|
|
|
exts=$(printf "%s\n%s\n%s\n%s\n" \
|
|
|
|
"subjectKeyIdentifier = hash" \
|
|
|
|
"authorityKeyIdentifier = keyid, issuer:always" \
|
|
|
|
"basicConstraints = CA:false" \
|
|
|
|
"proxyCertInfo = critical, @pcexts";
|
|
|
|
echo "[pcexts]";
|
|
|
|
for x in "$@"; do echo $x; done)
|
|
|
|
cert "$cert" "$exts" -CA "${ca}.pem" -CAkey "${cakey}.pem" \
|
|
|
|
-set_serial 2 -days "${DAYS}"
|
|
|
|
}
|
|
|
|
|
2021-12-03 01:26:15 +08:00
|
|
|
geneeconfig() {
|
|
|
|
local key=$1; shift
|
|
|
|
local cert=$1; shift
|
|
|
|
local cakey=$1; shift
|
|
|
|
local ca=$1; shift
|
|
|
|
local conf=$1; shift
|
|
|
|
|
|
|
|
exts=$(printf "%s\n%s\n%s\n%s\n" \
|
|
|
|
"subjectKeyIdentifier = hash" \
|
|
|
|
"authorityKeyIdentifier = keyid" \
|
|
|
|
"basicConstraints = CA:false"; \
|
|
|
|
echo "$conf")
|
|
|
|
|
|
|
|
cert "$cert" "$exts" -CA "${ca}.pem" -CAkey "${cakey}.pem" \
|
|
|
|
-set_serial 2 -days "${DAYS}"
|
|
|
|
}
|
|
|
|
|
2021-06-08 17:23:34 +08:00
|
|
|
# Usage: $0 geneealt keyname certname cakeyname cacertname alt1 alt2 ...
|
2016-06-22 20:36:08 +08:00
|
|
|
#
|
|
|
|
# Note: takes csr on stdin, so must be used with $0 req like this:
|
|
|
|
#
|
2021-06-08 17:23:34 +08:00
|
|
|
# $0 req keyname dn | $0 geneealt keyname certname cakeyname cacertname alt ...
|
2016-06-22 20:36:08 +08:00
|
|
|
geneealt() {
|
|
|
|
local key=$1; shift
|
|
|
|
local cert=$1; shift
|
|
|
|
local cakey=$1; shift
|
|
|
|
local ca=$1; shift
|
|
|
|
|
2021-12-03 01:26:15 +08:00
|
|
|
conf=$(echo "subjectAltName = @alts"
|
2016-06-22 20:36:08 +08:00
|
|
|
echo "[alts]";
|
2021-12-03 01:26:15 +08:00
|
|
|
for x in "$@"; do echo "$x"; done)
|
|
|
|
|
|
|
|
geneeconfig $key $cert $cakey $ca "$conf"
|
2016-06-22 20:36:08 +08:00
|
|
|
}
|
|
|
|
|
2016-01-15 16:48:27 +08:00
|
|
|
genee() {
|
|
|
|
local OPTIND=1
|
|
|
|
local purpose=serverAuth
|
2022-06-15 23:31:19 +08:00
|
|
|
local ku=
|
2016-01-15 16:48:27 +08:00
|
|
|
|
2022-06-15 23:31:19 +08:00
|
|
|
while getopts p:k: o
|
2016-01-15 16:48:27 +08:00
|
|
|
do
|
|
|
|
case $o in
|
|
|
|
p) purpose="$OPTARG";;
|
2022-06-15 23:31:19 +08:00
|
|
|
k) ku="keyUsage = $OPTARG";;
|
|
|
|
*) echo "Usage: $0 genee [-k KU] [-p EKU] cn keyname certname cakeyname cacertname" >&2
|
2016-01-15 16:48:27 +08:00
|
|
|
return 1;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
shift $((OPTIND - 1))
|
|
|
|
local cn=$1; shift
|
|
|
|
local key=$1; shift
|
|
|
|
local cert=$1; shift
|
|
|
|
local cakey=$1; shift
|
|
|
|
local ca=$1; shift
|
|
|
|
|
|
|
|
exts=$(printf "%s\n%s\n%s\n%s\n%s\n[alts]\n%s\n" \
|
|
|
|
"subjectKeyIdentifier = hash" \
|
|
|
|
"authorityKeyIdentifier = keyid, issuer" \
|
|
|
|
"basicConstraints = CA:false" \
|
2022-06-15 23:31:19 +08:00
|
|
|
"$ku" \
|
2016-01-15 16:48:27 +08:00
|
|
|
"extendedKeyUsage = $purpose" \
|
|
|
|
"subjectAltName = @alts" "DNS=${cn}")
|
2016-06-19 16:56:09 +08:00
|
|
|
csr=$(req "$key" "CN = $cn") || return 1
|
2016-01-15 16:48:27 +08:00
|
|
|
echo "$csr" |
|
|
|
|
cert "$cert" "$exts" -CA "${ca}.pem" -CAkey "${cakey}.pem" \
|
|
|
|
-set_serial 2 -days "${DAYS}" "$@"
|
|
|
|
}
|
|
|
|
|
2020-09-23 15:43:43 +08:00
|
|
|
geneeextra() {
|
|
|
|
local OPTIND=1
|
|
|
|
local purpose=serverAuth
|
|
|
|
|
|
|
|
while getopts p: o
|
|
|
|
do
|
|
|
|
case $o in
|
|
|
|
p) purpose="$OPTARG";;
|
|
|
|
*) echo "Usage: $0 geneeextra [-p EKU] cn keyname certname cakeyname cacertname extraext" >&2
|
|
|
|
return 1;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
shift $((OPTIND - 1))
|
|
|
|
local cn=$1; shift
|
|
|
|
local key=$1; shift
|
|
|
|
local cert=$1; shift
|
|
|
|
local cakey=$1; shift
|
|
|
|
local ca=$1; shift
|
|
|
|
local extraext=$1; shift
|
|
|
|
|
|
|
|
exts=$(printf "%s\n%s\n%s\n%s\n%s\n%s\n[alts]\n%s\n" \
|
|
|
|
"subjectKeyIdentifier = hash" \
|
|
|
|
"authorityKeyIdentifier = keyid, issuer" \
|
|
|
|
"basicConstraints = CA:false" \
|
|
|
|
"extendedKeyUsage = $purpose" \
|
|
|
|
"subjectAltName = @alts"\
|
|
|
|
"$extraext" "DNS=${cn}")
|
|
|
|
csr=$(req "$key" "CN = $cn") || return 1
|
|
|
|
echo "$csr" |
|
|
|
|
cert "$cert" "$exts" -CA "${ca}.pem" -CAkey "${cakey}.pem" \
|
|
|
|
-set_serial 2 -days "${DAYS}" "$@"
|
|
|
|
}
|
|
|
|
|
2019-08-08 18:08:14 +08:00
|
|
|
geneenocsr() {
|
|
|
|
local OPTIND=1
|
|
|
|
local purpose=serverAuth
|
|
|
|
|
|
|
|
while getopts p: o
|
|
|
|
do
|
|
|
|
case $o in
|
|
|
|
p) purpose="$OPTARG";;
|
2020-09-23 15:43:43 +08:00
|
|
|
*) echo "Usage: $0 geneenocsr [-p EKU] cn certname cakeyname cacertname" >&2
|
2019-08-08 18:08:14 +08:00
|
|
|
return 1;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
shift $((OPTIND - 1))
|
|
|
|
local cn=$1; shift
|
|
|
|
local cert=$1; shift
|
|
|
|
local cakey=$1; shift
|
|
|
|
local ca=$1; shift
|
|
|
|
|
|
|
|
exts=$(printf "%s\n%s\n%s\n%s\n%s\n[alts]\n%s\n" \
|
|
|
|
"subjectKeyIdentifier = hash" \
|
|
|
|
"authorityKeyIdentifier = keyid, issuer" \
|
|
|
|
"basicConstraints = CA:false" \
|
|
|
|
"extendedKeyUsage = $purpose" \
|
|
|
|
"subjectAltName = @alts" "DNS=${cn}")
|
|
|
|
cert "$cert" "$exts" -CA "${ca}.pem" -CAkey "${cakey}.pem" \
|
|
|
|
-set_serial 2 -days "${DAYS}" "$@"
|
|
|
|
}
|
|
|
|
|
2016-01-15 16:48:27 +08:00
|
|
|
genss() {
|
|
|
|
local cn=$1; shift
|
|
|
|
local key=$1; shift
|
|
|
|
local cert=$1; shift
|
|
|
|
|
|
|
|
exts=$(printf "%s\n%s\n%s\n%s\n%s\n[alts]\n%s\n" \
|
|
|
|
"subjectKeyIdentifier = hash" \
|
|
|
|
"authorityKeyIdentifier = keyid, issuer" \
|
|
|
|
"basicConstraints = CA:false" \
|
|
|
|
"extendedKeyUsage = serverAuth" \
|
|
|
|
"subjectAltName = @alts" "DNS=${cn}")
|
2016-06-19 16:56:09 +08:00
|
|
|
csr=$(req "$key" "CN = $cn") || return 1
|
2016-01-15 16:48:27 +08:00
|
|
|
echo "$csr" |
|
|
|
|
cert "$cert" "$exts" -signkey "${key}.pem" \
|
|
|
|
-set_serial 1 -days "${DAYS}" "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
gennocn() {
|
|
|
|
local key=$1; shift
|
|
|
|
local cert=$1; shift
|
|
|
|
|
|
|
|
csr=$(req_nocn "$key") || return 1
|
|
|
|
echo "$csr" |
|
|
|
|
cert "$cert" "" -signkey "${key}.pem" -set_serial 1 -days -1 "$@"
|
|
|
|
}
|
|
|
|
|
2020-01-23 07:24:35 +08:00
|
|
|
genct() {
|
|
|
|
local OPTIND=1
|
|
|
|
local purpose=serverAuth
|
|
|
|
|
|
|
|
while getopts p: o
|
|
|
|
do
|
|
|
|
case $o in
|
|
|
|
p) purpose="$OPTARG";;
|
|
|
|
*) echo "Usage: $0 genct [-p EKU] cn keyname certname cakeyname cacertname ctlogkey" >&2
|
|
|
|
return 1;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
shift $((OPTIND - 1))
|
|
|
|
local cn=$1; shift
|
|
|
|
local key=$1; shift
|
|
|
|
local cert=$1; shift
|
|
|
|
local cakey=$1; shift
|
|
|
|
local ca=$1; shift
|
|
|
|
local logkey=$1; shift
|
|
|
|
|
|
|
|
exts=$(printf "%s\n%s\n%s\n%s\n%s\n%s\n[alts]\n%s\n" \
|
|
|
|
"subjectKeyIdentifier = hash" \
|
|
|
|
"authorityKeyIdentifier = keyid, issuer" \
|
|
|
|
"basicConstraints = CA:false" \
|
|
|
|
"extendedKeyUsage = $purpose" \
|
|
|
|
"1.3.6.1.4.1.11129.2.4.3 = critical,ASN1:NULL"\
|
|
|
|
"subjectAltName = @alts" "DNS=${cn}")
|
|
|
|
csr=$(req "$key" "CN = $cn") || return 1
|
|
|
|
echo "$csr" |
|
|
|
|
cert "$cert" "$exts" -CA "${ca}.pem" -CAkey "${cakey}.pem" \
|
|
|
|
-set_serial 2 -days "${DAYS}" "$@"
|
|
|
|
cat ${cert}.pem ${ca}.pem > ${cert}-chain.pem
|
|
|
|
go run github.com/google/certificate-transparency-go/ctutil/sctgen \
|
|
|
|
--log_private_key ${logkey}.pem \
|
|
|
|
--timestamp="2020-01-01T00:00:00Z" \
|
|
|
|
--cert_chain ${cert}-chain.pem \
|
|
|
|
--tls_out ${cert}.tlssct
|
|
|
|
rm ${cert}-chain.pem
|
|
|
|
filesize=$(wc -c <${cert}.tlssct)
|
|
|
|
exts=$(printf "%s\n%s\n%s\n%s\n%s%04X%04X%s\n%s\n[alts]\n%s\n" \
|
|
|
|
"subjectKeyIdentifier = hash" \
|
|
|
|
"authorityKeyIdentifier = keyid, issuer" \
|
|
|
|
"basicConstraints = CA:false" \
|
|
|
|
"extendedKeyUsage = $purpose" \
|
|
|
|
"1.3.6.1.4.1.11129.2.4.2 = ASN1:FORMAT:HEX,OCT:" $((filesize+2)) $filesize `xxd -p ${cert}.tlssct | tr -d '\n'` \
|
|
|
|
"subjectAltName = @alts" "DNS=${cn}")
|
|
|
|
echo "$csr" |
|
|
|
|
cert "$cert" "$exts" -CA "${ca}.pem" -CAkey "${cakey}.pem" \
|
|
|
|
-set_serial 2 -days "${DAYS}" "$@"
|
|
|
|
}
|
|
|
|
|
2016-01-15 16:48:27 +08:00
|
|
|
"$@"
|