@@ -3316,6 +3316,11 @@ Unable to revoke as the input-file is not a valid certificate.
3316
3316
Certificate was expected at:
3317
3317
* $crt_in"
3318
3318
3319
+ # Forbid self-signed cert from being expired/renewed/revoked
3320
+ if forbid_selfsign "$crt_in"; then
3321
+ user_error "Cannot $cmd a self-signed certificate."
3322
+ fi
3323
+
3319
3324
# Verify request
3320
3325
if [ -f "$req_in" ]; then
3321
3326
verify_file req "$req_in" || user_error "\
@@ -3508,6 +3513,11 @@ Missing certificate file:
3508
3513
* $crt_in"
3509
3514
fi
3510
3515
3516
+ # Forbid self-signed cert from being expired/renewed/revoked
3517
+ if forbid_selfsign "$crt_in"; then
3518
+ user_error "Cannot $cmd a self-signed certificate."
3519
+ fi
3520
+
3511
3521
# get the serial number of the certificate
3512
3522
cert_serial=
3513
3523
ssl_cert_serial "$crt_in" cert_serial || \
@@ -3553,6 +3563,23 @@ It can be revoked with command 'revoke-expired'.
3553
3563
It is now possible to sign a new certificate for '$file_name_base'"
3554
3564
} # => expire_cert()
3555
3565
3566
+ # Forbid a self-signed cert from being expired/renewed/revoked
3567
+ # by a CA that has nothing to do with the cert
3568
+ forbid_selfsign() {
3569
+ # cert temp-file
3570
+ forbid_selfsign_tmp=
3571
+ easyrsa_mktemp forbid_selfsign_tmp || \
3572
+ die "easyrsa_mktemp forbid_selfsign_tmp"
3573
+
3574
+ # SSL text
3575
+ "$EASYRSA_OPENSSL" x509 -in "$1" -noout -text \
3576
+ > "$forbid_selfsign_tmp" || \
3577
+ die "forbid_selfsign - ssl text"
3578
+
3579
+ # test for CA:TRUE
3580
+ grep -q "^[[:blank:]]*CA:TRUE$" "$forbid_selfsign_tmp"
3581
+ } # => forbid_selfsign()
3582
+
3556
3583
# gen-crl backend
3557
3584
gen_crl() {
3558
3585
out_file="$EASYRSA_PKI/crl.pem"
0 commit comments