diff options
author | Erich Eckner <git@eckner.net> | 2019-08-29 13:33:02 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2019-08-29 13:33:02 +0200 |
commit | 0f6b01ed8265ddd01687ff8b50de52be8fcf97c0 (patch) | |
tree | 3a83dc2695a8a850f1371240f43ae2a4cab3641b | |
parent | e33c85c0f64dd1c0eb1612c10d2c2fbc66c98bae (diff) | |
download | simple-pki-0f6b01ed8265ddd01687ff8b50de52be8fcf97c0.tar.xz |
sign-ca: cross sign ca with old one
-rwxr-xr-x | sign-ca.in | 19 |
1 files changed, 17 insertions, 2 deletions
@@ -28,16 +28,31 @@ fi if [ ! -f "${key_dir}/${ca_name}.key.new" ] \ || [ ! -f "${key_dir}/${ca_name}.crt.new" ]; then - openssl req -x509 -new \ + openssl req -new \ -newkey rsa:4096 -sha256 \ -keyout "${key_dir}/${ca_name}.key.new" \ + -out "${key_dir}/${ca_name}.csr.new" \ + -nodes \ + -subj "${ca_subject_prefix}"'/CN=Certification Authority' \ + -addext 'subjectKeyIdentifier = hash' \ + -addext 'basicConstraints = critical, CA:true' \ + -addext 'keyUsage = keyCertSign, cRLSign' + if [ -f "${key_dir}/${ca_name}.key" ]; then + previous_key="${key_dir}/${ca_name}.key" + else + previous_key="${key_dir}/${ca_name}.key.new" + fi + openssl req -x509 \ + -sha256 \ + -in "${key_dir}/${ca_name}.csr.new" \ + -key "${previous_key}" \ -out "${key_dir}/${ca_name}.crt.new" \ -days 365 -nodes \ - -subj "${ca_subject}"'/CN=Certification Authority' \ -addext 'subjectKeyIdentifier = hash' \ -addext 'authorityKeyIdentifier = keyid:always, issuer' \ -addext 'basicConstraints = critical, CA:true' \ -addext 'keyUsage = keyCertSign, cRLSign' + rm "${key_dir}/${ca_name}.csr.new" fi rsync --ignore-missing-args \ |