@@ -28,7 +28,7 @@ For a list of utility commands, use:
28
28
./easyrsa help util
29
29
30
30
A list of commands is shown below:
31
- init-pki [ cmd-opts ]
31
+ init-pki
32
32
self-sign-server <file_name_base> [ cmd-opts ]
33
33
self-sign-client <file_name_base> [ cmd-opts ]
34
34
build-ca [ cmd-opts ]
@@ -123,12 +123,6 @@ Usage: easyrsa [ OPTIONS.. ] <COMMAND> <TARGET> [ cmd-opts.. ]"
123
123
* init-pki [ cmd-opts ]
124
124
125
125
Removes & re-initializes the PKI directory for a new PKI"
126
-
127
- opts="
128
- * hard - Recursively delete the ENTIRE PKI directory (default).
129
- * soft - Keep the named PKI directory and PKI 'vars' file intact.
130
- Also keep the current Request files,
131
- to be signed by a new CA (Partial CA renewal)."
132
126
;;
133
127
self-sign*)
134
128
text="
@@ -1398,23 +1392,6 @@ $verify_ca_help_note"
1398
1392
1399
1393
# init-pki backend:
1400
1394
init_pki() {
1401
- # Process command options
1402
- reset="hard"
1403
- while [ "$1" ]; do
1404
- case "$1" in
1405
- hard-reset|hard)
1406
- reset="hard"
1407
- confirm_msg=
1408
- ;;
1409
- soft-reset|soft)
1410
- reset="soft"
1411
- confirm_msg='PARTIALLY '
1412
- ;;
1413
- *) warn "Ignoring unknown command option: '$1'"
1414
- esac
1415
- shift
1416
- done
1417
-
1418
1395
# EasyRSA will NOT do 'rm -rf /'
1419
1396
case "$EASYRSA_PKI" in
1420
1397
.|..|./|../|.//*|..//*|/|//*|\\|?:|'')
@@ -1426,116 +1403,22 @@ init_pki() {
1426
1403
confirm "Confirm removal: " "yes" "
1427
1404
WARNING!!!
1428
1405
1429
- You are about to ${confirm_msg} remove the EASYRSA_PKI at:
1406
+ You are about to remove the EASYRSA_PKI at:
1430
1407
* $EASYRSA_PKI
1431
1408
1432
1409
and initialize a fresh PKI here."
1433
-
1434
- # now remove it:
1435
- case "$reset" in
1436
- hard)
1437
- # Promote use of 'init-pki soft':
1438
- confirm "
1439
- WARNING: COMPLETELY DESTROY current PKI (NOT recommended) ?
1440
-
1441
- [yes/NO]: " yes "\
1442
- ******************************************
1443
- * SECOND WARNING - STOP - SECOND WARNING *
1444
- ******************************************
1445
-
1446
- To keep your current 'pki/vars' settings use 'init-pki soft'.
1447
- To keep your current Request files use 'init-pki soft'
1448
- The Requests can then be signed by a new CA (Partial CA renewal)
1449
- To keep your current Easy-RSA TLS Key use 'init-pki soft'
1450
- This private key file is in use by your current VPN.
1451
-
1452
- ** USE OF 'init-pki soft' IS RECOMMENDED **${NL}"
1453
-
1454
- # # # shellcheck disable=SC2115 # Use "${var:?}"
1455
- rm -rf "$EASYRSA_PKI" || \
1456
- die "init-pki hard reset failed."
1457
- ;;
1458
- soft)
1459
- # There is no unit test for a soft reset
1460
- # Save existing TLS key
1461
- tls_key_file="$EASYRSA_PKI"/private/easyrsa-tls.key
1462
- old_tls_key_file="$EASYRSA_PKI"/easyrsa-keepsafe-tls.key
1463
-
1464
- # If both keys exist then they must be the same
1465
- if [ -f "$old_tls_key_file" ]; then
1466
- if [ -f "$tls_key_file" ]; then
1467
- # Match by hash
1468
- tls_key_hash="$(
1469
- "$EASYRSA_OPENSSL" dgst -sha256 \
1470
- "$tls_key_file")"
1471
- tls_key_hash="${tls_key_hash##* }"
1472
- old_tls_key_hash="$(
1473
- "$EASYRSA_OPENSSL" dgst -sha256 \
1474
- "$old_tls_key_file")"
1475
- old_tls_key_hash="${old_tls_key_hash##* }"
1476
- [ "$tls_key_hash" = "$old_tls_key_hash" ] || \
1477
- user_error "\
1478
- Easy-RSA TLS Keys do not match, only ONE of these files is valid:
1479
- * $tls_key_file
1480
- * $old_tls_key_file
1481
-
1482
- Please delete the key above that is no longer in use."
1483
- fi
1484
- fi
1485
-
1486
- # Save existing TLS key
1487
- if [ -f "$tls_key_file" ]; then
1488
- tls_key_data="$(cat "$tls_key_file")"
1489
- else
1490
- tls_key_data=
1491
- fi
1492
-
1493
- # Do NOT remove pki/reqs sub-dir, for "renew ca"
1494
- for i in ca.crt crl.pem \
1495
- issued private inline revoked renewed expired \
1496
- serial serial.old index.txt index.txt.old \
1497
- index.txt.attr index.txt.attr.old certs_by_serial
1498
- do
1499
- # # # shellcheck disable=SC2115 # Use "${var:?}"
1500
- target="$EASYRSA_PKI/$i"
1501
- if [ "${target%/*}" ]; then
1502
- rm -rf "$target" || \
1503
- die "init-pki soft reset(1) failed!"
1504
- else
1505
- die "init-pki soft reset(2) failed!"
1506
- fi
1507
- done
1508
- ;;
1509
- *)
1510
- user_error "Unknown reset type: $reset"
1511
- esac
1512
1410
fi
1513
1411
1412
+ # # # shellcheck disable=SC2115 # Use "${var:?}"
1413
+ rm -rf "$EASYRSA_PKI" || \
1414
+ die "init-pki hard reset failed."
1415
+
1514
1416
# new dirs:
1515
1417
easyrsa_mkdir "$EASYRSA_PKI"
1516
1418
for i in issued private reqs; do
1517
1419
easyrsa_mkdir "${EASYRSA_PKI}/$i"
1518
1420
done
1519
1421
1520
- # If one existed then recreate old TLS key backup file
1521
- if [ "$tls_key_data" ]; then
1522
- header="# Easy-RSA TLS Key: $(date)${NL}# DO NOT DELETE"
1523
- printf '%s\n\n%s\n' "$header" "$tls_key_data" \
1524
- > "$old_tls_key_file"
1525
- tls_msg="${NL}
1526
- Previous Easy-RSA TLS key saved to:
1527
- * $old_tls_key_file${NL}"
1528
- else
1529
- # if an OLD TLS key still exists then notify user
1530
- if [ -f "$old_tls_key_file" ]; then
1531
- tls_msg="${NL}
1532
- Existing Easy-RSA TLS key preserved:
1533
- * $old_tls_key_file${NL}"
1534
- else
1535
- tls_msg=
1536
- fi
1537
- fi
1538
-
1539
1422
# write pki/vars.example - no temp-file because no session
1540
1423
write_legacy_file_v2 \
1541
1424
vars "$EASYRSA_PKI"/vars.example overwrite || \
@@ -1553,7 +1436,7 @@ Your newly created PKI dir is:
1553
1436
select_vars
1554
1437
information "\
1555
1438
Using Easy-RSA configuration:
1556
- * ${EASYRSA_VARS_FILE:-undefined}${tls_msg} "
1439
+ * ${EASYRSA_VARS_FILE:-undefined}"
1557
1440
} # => init_pki()
1558
1441
1559
1442
# Find support files from various sources
@@ -1733,40 +1616,6 @@ Unable to create necessary PKI files (permissions?)"
1733
1616
> "$EASYRSA_PKI/serial" || die "$err_msg"
1734
1617
unset -v err_msg
1735
1618
1736
- # If one exists then recreate TLS Key
1737
- tls_key_file="$EASYRSA_PKI"/private/easyrsa-tls.key
1738
- old_tls_key_file="$EASYRSA_PKI"/easyrsa-keepsafe-tls.key
1739
- if [ -f "$old_tls_key_file" ]; then
1740
- confirm "Re-install existing Easy-RSA TLS Key ? " yes "
1741
- An Easy-RSA TLS Key, saved by 'init-pki soft', has been found.
1742
- This TLS Key is in use by your VPN, it is recommended that you
1743
- re-install this TLS Key.
1744
-
1745
- Note:
1746
- This is a private key and will NOT be added to new inline files.
1747
-
1748
- To create a new Easy-RSA TLS Key, delete this old TLS Key above."
1749
- cp "$old_tls_key_file" "$tls_key_file" || \
1750
- warn "Failed to install TLS Key!"
1751
- tls_key_msg="${NL}
1752
- NOTICE: The previous Easy-RSA TLS Key has been installed:
1753
- * $tls_key_file
1754
-
1755
- This TLS Key will NOT be added to new inline files. These new
1756
- inline files can then be easily distributed to your servers and
1757
- clients. The TLS Key that your servers and clients have previously
1758
- received, can be added to the inline file manually.
1759
-
1760
- To re-enable automatically adding this TLS Key to inline files,
1761
- simply delete the backup TLS Key at:
1762
- * $old_tls_key_file
1763
-
1764
- To create a new Easy-RSA TLS Key, delete both TLS Keys above."
1765
- else
1766
- tls_key_msg="${NL}
1767
- Create an OpenVPN TLS-AUTH|TLS-CRYPT-V1 key now: See 'help gen-tls'"
1768
- fi
1769
-
1770
1619
# Set ssl batch mode, as required
1771
1620
[ "$EASYRSA_BATCH" ] && ssl_batch=1
1772
1621
@@ -2002,7 +1851,7 @@ Prior to signing operations, place your resulting Sub-CA cert at:
2002
1851
else
2003
1852
notice "\
2004
1853
CA creation complete. Your new CA certificate is at:
2005
- * $out_file${tls_key_msg}
1854
+ * $out_file
2006
1855
2007
1856
Build-ca completed successfully."
2008
1857
fi
0 commit comments