Commit Graph
1396 Commits
Author SHA1 Message Date
Richard T Bonhomme 4c8a4e8765 Command renew: Require CSR as input file and refactor verification
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-17 21:51:39 +00:00
Richard T Bonhomme b4dc2ad0ea Command renew: Process options correctly and minor improvements
Process options correctly:
* This removes an errant 'shift' when processing options.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-17 21:45:23 +00:00
Richard T Bonhomme 97fec2de61 Merge branch 'TinCanTech-win-build-ca'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-15 19:57:34 +00:00
Richard T Bonhomme 74e512252c Merge branch 'win-build-ca' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-win-build-ca
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-15 19:56:55 +00:00
Richard T Bonhomme 0ce126a289 build-ca: Error-exit on failure to write temp-CA-passphrase files
Also, prototype easyrsa_mktemp() errors.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-13 00:02:28 +00:00
Richard T Bonhomme 9a495f7bd3 build-ca: Use OpenSSL '-passout' with EasyRSA '--passout' correctly
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-12 21:22:44 +00:00
Richard T Bonhomme 0063de0d88 Allow default CA generation method to be unit-tested
If 'easyrsa' is being run by the unit-test then allow the default method
for 'build-ca' to be exercised.

The default 'easyrsa' method is to use temp-files, generated by EasyRSA,
to pass the CA passphrase, provided by the user, to the SSL command.

The normal 'unit-test' method to use a passphrase is to configure EasyRSA
ommand line options '--passin' and '--passout'.

The change made here is to simulate user-interaction and to supply a
default passphrase, as a user, to the SSL command.
To NOT use EasyRSA command line options to set any passphrase.
ONLY when being run by the unit-test.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-11 22:37:40 +00:00
Richard T Bonhomme 8ae6bca3dc Windows, build-ca: Add input password to re-open private key
Using OpenSSL 3.0.7, packaged by OpenVPN Windows installer, causes
EasyRSA command 'build-ca' to fail, because it does not have an input
password to re-open the private key, which is required to generate
the CA certificate.

Provide the user specified CA passphrase as input password for build-ca.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-11 22:29:35 +00:00
Richard T Bonhomme bec781d3fe Merge branch 'TinCanTech-sanatize_and_set_var'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-11 12:56:23 +00:00
Richard T Bonhomme b5228f76d0 Merge branch 'sanatize_and_set_var' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-sanatize_and_set_var
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-11 12:55:38 +00:00
Richard T Bonhomme d3f4cb4d02 ssl_cert_not_after_date(): Use safe_set_var()
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-10 14:26:46 +00:00
Richard T Bonhomme ec184ca49e ssl_cert_not_before_date(): Use safe_set_var()
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-10 14:14:19 +00:00
Richard T Bonhomme 8f71f71d8e build-ca: Use safe_set_var()
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-10 13:29:56 +00:00
Richard T Bonhomme b578efcb50 New function safe_set_var(): Safe wrapper for set_var()
When using set_var() with a variable as in input for name of the variable,
use this wrapper to verify the input is suitable as a variable name.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-10 13:17:39 +00:00
Richard T Bonhomme 8ca58f11ad Merge branch 'TinCanTech-index-expire'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-10 00:22:13 +00:00
Richard T Bonhomme fcac1fe499 Merge branch 'index-expire' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-index-expire
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-10 00:21:20 +00:00
Richard T Bonhomme 01ded61201 Wrap long lines for code close by to status report functions
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-09 22:48:11 +00:00
Richard T Bonhomme abad51a4f3 Status reports: Recognise Expired certificates
Command show-expire:
Improve report outut to show 'expired: <date>' for expired certificates.
Otherwise, show 'expires: <date>' for currently Valid certicates.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-09 22:26:58 +00:00
Richard T Bonhomme 3ce9272e3a easyrs_openssl(): Correct comment only
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-08 02:03:29 +00:00
Richard T Bonhomme 808b025f8a Merge branch 'TinCanTech-easyrsa_openssl-vs-debug'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-08 01:26:33 +00:00
Richard T Bonhomme 8ecdc349e9 Merge branch 'easyrsa_openssl-vs-debug' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-easyrsa_openssl-vs-debug
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-08 01:25:50 +00:00
Richard T Bonhomme 591924d631 Stop EASYRSA_DEBUG interfering with SSL output from subshells
Some commands must capture the SSL output via a subshell.
eg: ssl_cert_serial() and ssl_cert_not_before/after_date()

To use easyrsa_openssl() for these commands, EASYRSA_DEBUG must be disabled.
This patch unsets EASYRSA_DEBUG in the function subshells only.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-08 00:58:43 +00:00
Richard T Bonhomme f97a3b7a93 Merge branch 'TinCanTech-reorder-easyrsa_openssl'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-08 00:51:30 +00:00
Richard T Bonhomme 2396ac21a2 Merge branch 'reorder-easyrsa_openssl' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-reorder-easyrsa_openssl
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-08 00:50:48 +00:00
Richard T Bonhomme 2b5150ea6c Merge branch 'TinCanTech-ff-date-to-cert-date-v2'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-08 00:45:15 +00:00
Richard T Bonhomme 8b85a3a349 Merge branch 'ff-date-to-cert-date-v2' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-ff-date-to-cert-date-v2
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-08 00:44:27 +00:00
Richard T Bonhomme 8ede536206 Re-order easyrsa_openssl() temp-file assignment
Always assign the easyrsa_openssl() temp-file before escape_hazard().
In the event of failure, easyrsa_openssl() will try first.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-08 00:17:17 +00:00
Richard T Bonhomme 3c0d90799f ff_date_to_cert_date(): Correct the input format for busybox date
Also, correct alignment and indents with no functional change.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-07 23:15:04 +00:00
Richard T Bonhomme 9266caaf33 verify_ssl_lib(): short-circuit overload check; un-indent by one tab
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-07 02:15:01 +00:00
Richard T Bonhomme aa85739b2e Merge branch 'TinCanTech-no-safe-ssl-mode'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-06 22:53:33 +00:00
Richard T Bonhomme f3b2f60678 Merge branch 'no-safe-ssl-mode' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-no-safe-ssl-mode
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-06 22:46:48 +00:00
Richard T Bonhomme c5d401651c Introduce OpenSSL only mode: No Safe SSL Config File
Global option '--no-safe-ssl' disables generating a safe SSL config file.

The default is to always generate a safe SSL config file.

Can be used by OpenSSL ONLY.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-05 20:44:28 +00:00
Richard T Bonhomme d167b517f7 Merge branch 'TinCanTech-always-use-easyrsa_openssl'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-04 20:35:39 +00:00
Richard T Bonhomme 4be21f8fd2 Merge branch 'always-use-easyrsa_openssl' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-always-use-easyrsa_openssl
PLUS: Minor changes to error meesage output only, no functional changes.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-04 20:33:31 +00:00
Richard T Bonhomme 886002b089 Rename function variable
fn_ is preferable to f_

This is to simulate 'local', which was not POSIX, until recently.
Baseline: Windows sh.exe

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-04 12:17:04 +00:00
Richard T Bonhomme c3943edd28 Replace use of $EASYRSA_OPENSSL with easyrsa_openssl()
Use replaced in display_san() and display_dn().

verify_file(): Return status of SSL command.

Wrap long lines x4.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-03 21:34:31 +00:00
Richard T Bonhomme 3caf0ec905 Replace SSL calls for serial number with function ssl_cert_serial()
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-03 19:21:21 +00:00
Richard T Bonhomme ec56603b91 Merge branch 'TinCanTech-set-OPENSSL_CONF'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-03 13:09:03 +00:00
Richard T Bonhomme 6535998aaa Merge branch 'set-OPENSSL_CONF' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-set-OPENSSL_CONF
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-03 13:08:19 +00:00
Richard T Bonhomme 80b24532cb easyrsa_openssl(): Always set OPENSSL_CONF to EasyRSA safe SSL config
LibreSSL Always probes the file assigned by environment variable OPENSSL_CONF.
Default can be found via command 'openssl version -d'

EasyRSA MUST provide a suitable "safe" SSL config file to LibreSSL.

Therefore, all SSL calls made by EasyRSA SHOULD go via easyrsa_openssl(),
which can be forced to ALWAYS build a "safe" SSL config file.

By always building a "safe" SSL config file, EasyRSA can always configure
the default value for OPENSSL_CONF.

This patch changes easyrsa_openssl(), to force generation of a safe SSL
config on EVERY use and set OPENSSL_CONF to the same.

Calls to easyrsa_openssl() ALWAYS generate a safe SSL config file, however,
that config file is only called via SSL option '-config' when the command
requires an SSL config file. (As by original design)

The environment variable OPENSSL_CONF always points to the EasyRSA "safe" SSL
config file, although the SSL command may not support the '-config' option.

The fundemental changes made here are, easyrsa_openssl():
- ALWAYS creates a "safe" SSL config file, although it may not be required.
- ALWAYS assigns SSL env-var OPENSSL_CONF to the above "safe" SSL config file.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-03 02:56:30 +00:00
Richard T Bonhomme d15645b933 verify_ssl_lib(): On failure, capture SSL-lib error output
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-02 19:55:10 +00:00
Richard T Bonhomme 26b3877407 Merge branch 'TinCanTech-rename-temp-file'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-02 13:40:52 +00:00
Richard T Bonhomme 08f9dfd82b Merge branch 'rename-temp-file' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-rename-temp-file
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-02 13:39:39 +00:00
Richard T Bonhomme 3d90bd6c61 easyrsa_openssl(): Rename temp-file to reflect the purpose
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-02 13:29:21 +00:00
Richard T Bonhomme def581ec59 escape_hazard(): Rename temp-file to reflect the purpose
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-02 13:14:13 +00:00
Richard T Bonhomme d782bf8303 Merge branch 'TinCanTech-err_out-random'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-02 12:55:22 +00:00
Richard T Bonhomme b54d0f09a0 Merge branch 'err_out-random' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-err_out-random
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-02 12:54:07 +00:00
Richard T Bonhomme e2402d4561 Remove all prerequisite code to build a safe SSL config file
The code being removed was used to always build a safe SSL config file
during 'init-pki' and before running most other commands.  The reason
for this code was because LibreSSL throws an error for missing config
file when generating random numbers.

The first part of the change here is to redirect LibreSSL error-out to
'/dev/null', when generating random numbers, and only capture the random
number that is generated.

The second part is to remove all the code that built a safe SSL config
file prior to running all commands, so that a safe SSL config was always
present in the PKI. This is no longer required.

The third part is to improve and document command 'make-safe-ssl'.

The final result is that 'easyrsa_openssl()' is used as required, to
build a safe SSL config file on demand, as was the original design.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-01 12:58:19 +00:00
Richard T Bonhomme b6e73a45af Merge branch 'TinCanTech-remove-opts-verbose-quiet'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-11-30 21:40:36 +00:00
Richard T Bonhomme af73c4ce4f Merge branch 'remove-opts-verbose-quiet' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-remove-opts-verbose-quiet
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-11-30 21:38:40 +00:00