summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCorey Cothrum <contact@coreycothrum.com>2020-12-08 08:29:48 -0600
committerJia Zhang <zhang.jia@linux.alibaba.com>2020-12-09 09:16:29 +0800
commit8adff592ef39d2a07b8a22ab46245f52fa945eaa (patch)
tree5b34064b9d4d9dd4f749be860b02c3de49193fe4
parentd6ca3fa224c51ced1c511d59cbd85a6f35245748 (diff)
downloadmeta-secure-core-8adff592ef39d2a07b8a22ab46245f52fa945eaa.tar.gz
create-user-key-store.sh: allow user to specify openssl x509 'days' param
allow openssl x509 '--days' parameter to be specified via command line argument Signed-off-by: Corey Cothrum <contact@coreycothrum.com>
-rwxr-xr-xmeta-signing-key/scripts/create-user-key-store.sh10
1 files changed, 8 insertions, 2 deletions
diff --git a/meta-signing-key/scripts/create-user-key-store.sh b/meta-signing-key/scripts/create-user-key-store.sh
index 30e3c28..0d55d2a 100755
--- a/meta-signing-key/scripts/create-user-key-store.sh
+++ b/meta-signing-key/scripts/create-user-key-store.sh
@@ -5,6 +5,7 @@ _D=`dirname "$_S"`
5ROOT_DIR="`cd "$_D" && pwd`" 5ROOT_DIR="`cd "$_D" && pwd`"
6 6
7KEYS_DIR="$ROOT_DIR/user-keys" 7KEYS_DIR="$ROOT_DIR/user-keys"
8OPENSSL_DAYS="3650"
8GPG_KEYNAME= 9GPG_KEYNAME=
9GPG_EMAIL= 10GPG_EMAIL=
10GPG_COMMENT= 11GPG_COMMENT=
@@ -49,6 +50,8 @@ Options:
49 -bgp <Boot Loader GPG passphrase> 50 -bgp <Boot Loader GPG passphrase>
50 -bp <Boot loader config password> 51 -bp <Boot loader config password>
51 -ip <IMA passphrase> 52 -ip <IMA passphrase>
53 --days Specify the number of days to make a certificate valid for
54 Default: $OPENSSL_DAYS
52 -h|--help Show this help information. 55 -h|--help Show this help information.
53Overides: 56Overides:
54 -bc <gpg key comment> 57 -bc <gpg key comment>
@@ -133,6 +136,9 @@ while [ $# -gt 0 ]; do
133 -ip) 136 -ip)
134 shift && IMA_PASS="$1" 137 shift && IMA_PASS="$1"
135 ;; 138 ;;
139 --days)
140 shift && OPENSSL_DAYS="$1"
141 ;;
136 -h|--help) 142 -h|--help)
137 show_help `basename $0` 143 show_help `basename $0`
138 exit 0 144 exit 0
@@ -173,7 +179,7 @@ ca_sign() {
173 # Self signing ? 179 # Self signing ?
174 if [ "$key_name" = "$ca_key_name" ]; then 180 if [ "$key_name" = "$ca_key_name" ]; then
175 openssl req -new -x509 -newkey rsa:2048 \ 181 openssl req -new -x509 -newkey rsa:2048 \
176 -sha256 -nodes -days 3650 \ 182 -sha256 -nodes -days $OPENSSL_DAYS \
177 -subj "$subject" \ 183 -subj "$subject" \
178 -keyout "$key_dir/$key_name.key" \ 184 -keyout "$key_dir/$key_name.key" \
179 -out "$key_dir/$key_name.crt" \ 185 -out "$key_dir/$key_name.crt" \
@@ -223,7 +229,7 @@ ca_sign() {
223 -CA "$ca_cert" \ 229 -CA "$ca_cert" \
224 -CAform "$ca_cert_form" \ 230 -CAform "$ca_cert_form" \
225 -CAkey "$ca_key_dir/$ca_key_name.key" \ 231 -CAkey "$ca_key_dir/$ca_key_name.key" \
226 -set_serial 1 -days 3650 \ 232 -set_serial 1 -days $OPENSSL_DAYS \
227 -extfile "$ROOT_DIR/openssl.cnf" -extensions v3_req \ 233 -extfile "$ROOT_DIR/openssl.cnf" -extensions v3_req \
228 -out "$key_dir/$key_name.crt" \ 234 -out "$key_dir/$key_name.crt" \
229 || print_fatal "openssl failure" 235 || print_fatal "openssl failure"