Commit Graph
970 Commits
Author SHA1 Message Date
Richard T Bonhomme 8df0346f39 Minor improvements to revoke/renew/revoke-renewed
Tested manually.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-27 23:35:50 +01:00
Richard T Bonhomme ac12dad028 General improvements to revoke/renew/revoke-renewed
Ensure that declaration of file-names which are from serial-numbers
are declared after the serial-number has been extracted.

Move confirmation prompts to the last point before action.

Correct and improve #comments, "prompts" and "error messages".

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-27 22:31:19 +01:00
Richard T Bonhomme 345341013c ChangeLog: Add 'revoke-renewed'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-27 21:21:27 +01:00
Richard T Bonhomme 590c9787e7 Merge branch 'TinCanTech-revoke-renewed'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-27 20:10:03 +01:00
Richard T Bonhomme ef22701878 Introduce 'revoke-renewed'
When easyrsa "renews" a certificate, the current certificate is moved
to a sub-directory for renewed certificates and renamed to the serial
number of the certificate.

This makes it difficult to subsequently revoke the old certificate.

The new behaviour is for easyrsa to move the certificate without
renaming the file.  This means the certificate can be revoked by name.

Once a renewed certificate is revoked, it is moved to the 'revoked'
sub-directory, along with all other revoked certificates.

The same mechanism also manages keys, requests, PKCS and inline files.

Behaviour summary:

* revoke moves certificates to 'revoked' - Unchanged
  Rename the certificate to its serial number - Unchanged

* renew moves certificates to 'renewed' - Unchanged
  renew does not rename the certificate to its serial number - Changed

  Important:
  Only one certificate of a specific name (eg. john) can be renewed
  at the same time.
  To renew another certificate called 'john' the first MUST be revoked.

* revoke-renewed:
  takes the certificate from 'renewed' - Changed
  moves the certifiate to 'revoked' - Changed
  renames the certificate to its serial number - Unchanged

* All revoked certificates are moved to the 'revoked' sub-directory.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-27 19:27:34 +01:00
Richard T Bonhomme 0238b5cdba When $want_init_pki is set then also skip session setup
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-27 14:39:24 +01:00
Richard T Bonhomme f5a3950699 Merge branch 'TinCanTech-revoke-v2'
Plus a minor correction to order of checks.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-27 11:40:59 +01:00
Richard T Bonhomme 7914255760 Add "reason" check
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-27 03:28:23 +01:00
Richard T Bonhomme fdcaf6cf79 revoke(): Purge unquoted $opts + General improvements
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-27 02:40:11 +01:00
Richard T Bonhomme 3cff9494af Consolidate 'nopass' for PKCS export functions
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-26 17:51:00 +01:00
Richard T Bonhomme c1765bb54f Add 'nopass' option to 'export-p12' command
Plus a minor correction to white-space.

Closes: #411

Original commit:

commit e93af47b0112b13e221a1bf28d36afaf5f5719df
Author: itaru2622 <itaru2622@gmaiil.com>
Date:   Wed Oct 7 20:47:26 2020 +0900

    supporting nopass option for export-p12

    usage:
      easyrsa export-p12 EntityName nopass

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-26 15:51:50 +01:00
Richard T Bonhomme d9ec677ac7 Introduce 'show-crl'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-26 00:44:37 +01:00
Richard T Bonhomme a703f30e37 Only log SSL Library version once
Move the 'fi' below the output, restore old behaviour.

Minor improvments to readability:
* Make "No Safe SSL config-file" the default.
  OpenSSL does not require a "Safe" config-file, only LibreSSL does.
  Change from $no_safe_ssl_conf to $require_safe_ssl_conf.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-25 22:56:28 +01:00
Richard T Bonhomme d199389217 Introduce 'show-crl' - Simply show the CRL -text (No options)
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-25 21:19:22 +01:00
Richard T Bonhomme 8e8a11be1d Align help text
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-25 20:01:59 +01:00
Richard T Bonhomme dafaab0890 Always use SSL library directly for 'rand'
EasyRSA requires the output of the 'rand' command, not a file.
When EASYRSA_DEBUG is enabled the dubug output interferes with
easyrsa random requirements.

Also, disable using easyrsa_openssl() for rand.

Also, always die on SSL errors for random number generation.

Also, minor improvements to error messages.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-25 19:08:23 +01:00
Richard T Bonhomme 8ed43f9c67 Minor improvements and corrections to export_pkcs() and related help
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-25 16:25:00 +01:00
Richard T Bonhomme 30954cfdb6 Merge branch 'nkakouros-pkcs1'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-25 16:01:37 +01:00
nkakouros b80ec52810 Merge branch 'master' into pkcs1 2022-04-25 16:37:45 +03:00
Richard T Bonhomme 7e3242b636 Merge branch 'jdelker-pkcs12_alias'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-25 13:00:43 +01:00
Richard T Bonhomme 51857fbeca Merge branch 'pkcs12_alias' of ssh://github.com/jdelker/easy-rsa into jdelker-pkcs12_alias
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-25 12:53:54 +01:00
Richard T Bonhomme 33a4914abb renew() - Ensure CA index.txt.attr has 'unique_subject = no'
This is required to support renewal of a certificate.

Closes: #419

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-25 12:08:18 +01:00
Joerg Delker 2c71e06e0b changed option name to usefn 2022-04-24 23:39:30 +02:00
Richard T Bonhomme 69819242db Remove obsolete shellcheck commentary and dispose of a short-circuit
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-24 20:42:29 +01:00
Richard T Bonhomme 554dfa56a4 Correct 'date' and 'cp' syntax for Busybox
Add new 'date' test to identify a working command.

Also:
Remove the '-n' "no clobber" option from 'cp' in install_data_to_pki().
Rely on the shell to determine if 'vars' exists.

Closes: #543

Also:
Correctly quote related expansions.

Also:
Minor improvements to host detection.

Unit test completed on Alpine Linux with Busybox v1.34.1

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-24 20:21:32 +01:00
Joerg Delker 33acf0db1b added option to set PKCS#12 alias name 2022-04-24 20:16:09 +02:00
Richard T Bonhomme 133d7c7843 Allow OpenSSL to function without a "Safe" ssl-configuration file
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-23 22:30:16 +01:00
Richard T Bonhomme d3f4fdb177 Wrap two long lines (No functional change)
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-23 20:09:26 +01:00
Richard T Bonhomme 1ba11bfd12 Always keep locally installed binaries during clean up
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-23 20:04:38 +01:00
Richard T Bonhomme 5af34056cb Standardise use of 'case' - Provide default '*)' for all usage.
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-23 16:37:38 +01:00
Richard T Bonhomme dea7ca4f40 Replace '--verbose' mode with $EASYRSA_DUBUG
$EASYRSA_DUBUG must be deliberately set outside of easyrsa.

'--verbose' mode was a bad hack.

$EASYRSA_DUBUG is also broken from the start but it is the simplest way
to verify what data is being fed to SSL.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-22 22:49:57 +01:00
Richard T Bonhomme 867444b705 Remove Obsolete shellcheck directives for 2086, unquoted variables
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-22 21:21:25 +01:00
Richard T Bonhomme 2396b2f41a Refactor export_pkcs() - Quote all expansions (#494)
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-22 21:00:28 +01:00
Richard T Bonhomme 4b9b3ed657 Exporting P7b files does not support password information
Remove EasyRSA addition: '-pass $EASYRSA_PASSIN/OUT'

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-22 20:41:32 +01:00
Richard T Bonhomme 9b4bd19545 Refactor set_pass() - Quote all expansions (#494)
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-22 17:53:21 +01:00
Richard T Bonhomme a466f96b4e Refactor display_san() and display_dn() - Quote all exansions (#494)
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-22 17:32:58 +01:00
Richard T Bonhomme 2a9cd44902 Refactor default_server_san() - Quote all expansions (#494)
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-22 17:21:27 +01:00
Richard T Bonhomme 757b2776d7 Refactor show() - Quote all expansions (#494)
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-22 17:17:51 +01:00
Richard T Bonhomme ceb9a2093c Refactor show_ca() - Quote all expansions (#494)
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-22 17:07:11 +01:00
Richard T Bonhomme bf19e794d3 Correction to: 59dc15ac51
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-21 01:46:10 +01:00
Richard T Bonhomme 59dc15ac51 vars_setup(): Remove $vars_in_pki, unused.
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-21 01:42:30 +01:00
Richard T Bonhomme 8d82501fd0 Minor improvements to vars_setup() and build_ca()
These changes are only for readabilty and simplicity.
No functional changes.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-20 22:33:21 +01:00
Richard T Bonhomme 9a8e77e043 install_data_to_pki(): Use 'cp --no-clobber' to install a blank vars
In the context of 'vars-setup', install_data_to_pki() will only copy
the example vars file to a live vars file in the event that no other
vars file exists.   This final check will never over-write vars file
which is in the PKI.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-20 22:18:41 +01:00
Richard T Bonhomme df526695d8 Prioritise detecting host OS over setting defaults
This allows EasyRSA to detect and use OpenSSL shipped with
Git-for-Windows.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-20 22:14:11 +01:00
Richard T Bonhomme a0ed1203f2 Priorise trap above vars_setup()
vars_setup() has become more complex, therefore, trap should be set earlier.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-20 22:06:25 +01:00
Richard T Bonhomme 59ff47420c Merge branch 'TinCanTech-build-ca-v2'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-20 20:57:10 +01:00
Richard T Bonhomme e80c229559 Make build-ca() almost completely SSL library version independent
The only option which is not SSL version independent is:
  -nodes (version 1)
  -noenc (version 3)
This is managed via $no_password, which is set by verify_ssl_lib().

* Use SSL 'genpkey' to create All CA private keys.
  'genpkey' options are SSL version independent.

* Use SSL 'req' to create All CA certificate/key pairs.
  'req' options are SSL version independent.

* Replace $opts, $crypto and $crypto_opts with individual variables
  for each purpose.

* '$opts' usage:
  -x509 - Replaced by $x509
  -date - Replaced by $date_stamp ($date would be too common)
  -batch - Replaced by $ssl_batch

* '$crypto' usage:
  -aes256 - Replaced by $cipher

* '$crypto_opts' usage:
  -aes256 - Replaced by $cipher (2nd layer of unnecessary complexity)
  -nodes/-noenc - Replaced by $no_password

* Additional variable $digest for SSL 'req' - Defaults to '-sha256'

Insert $EASYRSA_EXTRA_EXTS into the config file along with x509-types
files 'ca' and COMMON.  Replaces the previous method of passing SSL
option '-addext foo:bar' directly to SSL command.

Create new EasyRSA option '--verbose'.  This prints the command passed
to the SSL library by easyrsa_openssl().

Add a shellcheck directive to install_data_to_pki().

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-20 15:52:20 +01:00
Richard T Bonhomme 0cf547feab Add placeholder for CA $X509_TYPES and $EXTRA_EXTS
Placeholder: %CA_X509_TYPES_EXTRA_EXTS%

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-20 14:37:32 +01:00
Richard T Bonhomme adc2cbed58 Check status of command, not exit-code, in default_server_san()
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-19 15:27:20 +01:00
Richard T Bonhomme 60f3fc2728 Quote $cert_ext_key_usage in renew()
'case' is "immune" to standard word splitting and globbing but
code-style now demands that 'case' does not get treated differently.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-19 15:20:54 +01:00