1365 Commits

Author SHA1 Message Date
Richard T Bonhomme
66d282e1c1
set-var(): Check input, die on errors
Previously, set_var() had no input checking, combined with
the point that, via vars, set_var() is user facing, this
can lead to easy user errors.

Now, input is checked:
- Parameter 1 is required.
- Parameter 1 cannot contain a space.
- Less-than 3 input parameters are expected.
- Quote the expansion of the first occurence of parameter 1
  in the evaluated expression.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-02-09 20:47:15 +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
Richard T Bonhomme
195d6e6c73
Update: Remove option '--quiet'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-11-29 23:52:36 +00:00
Richard T Bonhomme
fb198b17e2
Remove global options '--verbose' and '--quiet' as not required
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-11-29 23:34:46 +00:00
Richard T Bonhomme
37f9d3768e
build-ca: Remove unnecessary 'elif' check
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-11-28 00:02:22 +00:00
Richard T Bonhomme
a51278be73
Merge branch 'TinCanTech-get-ca-password'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-11-27 16:57:49 +00:00
Richard T Bonhomme
021f443f11
Merge branch 'get-ca-password' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-get-ca-password
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-11-27 16:56:53 +00:00
Richard T Bonhomme
c599bb1da7
build-ca: Improve passphrase input mechanism
Make EasyRSA check for basic passphrase requirements.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-11-27 01:38:20 +00:00
Richard T Bonhomme
ed01426a8b
Merge branch 'TinCanTech-use-unset-dash-v'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-11-24 18:15:05 +00:00
Richard T Bonhomme
4c2a89e657
Merge branch 'use-unset-dash-v' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-use-unset-dash-v
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-11-24 18:14:09 +00:00
Richard T Bonhomme
374d8f0cae
Use 'unset -v', consistently
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-11-24 18:10:08 +00:00
Richard T Bonhomme
fbaf67c118
Merge branch 'TinCanTech-update-vars-example'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-11-24 17:29:18 +00:00
Richard T Bonhomme
a3f33eb246
Merge branch 'update-vars-example' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-update-vars-example
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-11-24 17:28:35 +00:00
Richard T Bonhomme
a144d36450
Merge branch 'TinCanTech-minor-improve-and-format'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-11-24 17:27:17 +00:00
Richard T Bonhomme
fbf2437f8d
Merge branch 'minor-improve-and-format' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-minor-improve-and-format
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-11-24 17:26:21 +00:00
Richard T Bonhomme
5c36c478fb
vars.example: Add EASYRSA_NO_PASS and wrap long lines
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-11-23 21:53:46 +00:00
Richard T Bonhomme
dbe894dec6
Update help: Standardise output; Improve code; Reprioritise options
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-11-23 21:42:03 +00:00
Richard T Bonhomme
aa9a3d44fa
Merge branch 'TinCanTech-SIGINT-exit'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-11-22 18:22:57 +00:00
Richard T Bonhomme
a8d7f3d50f
Merge branch 'SIGINT-exit' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-SIGINT-exit
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-11-22 18:22:12 +00:00
Richard T Bonhomme
b03fe439e6
Merge branch 'TinCanTech-fix-sc-case-warn'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-11-22 16:38:25 +00:00
Richard T Bonhomme
68c7f63773
Merge branch 'fix-sc-case-warn' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-fix-sc-case-warn
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-11-22 16:37:34 +00:00
Richard T Bonhomme
a7e837cf92
Fix shellcheck warning for command set-pass case statement
Plus minor improvement to set-pass help text.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-11-22 16:23:00 +00:00
Richard T Bonhomme
f8a5f46f1d
Minor improvements to help for cmd:'set-pass' and opt:'--no-pass'
Squashed commit of the following:

commit 4f142baa04227963f291948dcbe2cb08e6ac6cd1
Merge: 0ee7a6d bcc71d6
Author: Richard T Bonhomme <tincantech@protonmail.com>
Date:   Mon Nov 21 20:23:22 2022 +0000

    Merge branch 'doc-set-pass' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-doc-set-pass

    Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>

commit bcc71d6c7e0d7bfe1d628cadc13689eb32fd4c8d
Author: Richard T Bonhomme <tincantech@protonmail.com>
Date:   Mon Nov 21 15:14:27 2022 +0000

    Minor improvements to help for cmd:'set-pass' and opt:'--no-pass'

    Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-11-21 20:26:08 +00:00
Richard T Bonhomme
3cb322049a
cleanup(): Exit correctly for SIGINT
Also, replace $die_error_exit with $confirm_aborted:
Make die() the default exit on error.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-11-20 20:54:52 +00:00
Richard T Bonhomme
0ee7a6d75e
Minor refactor: escape_hazard()
Squashed commit of the following:

commit 81937721412478c0f4b7d32b6a55d18099608d88
Merge: 43d7648 345e6cc
Author: Richard T Bonhomme <tincantech@protonmail.com>
Date:   Sun Nov 20 13:37:05 2022 +0000

    Merge branch 'improve-escape_hazard' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-improve-escape_hazard

    Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>

commit 345e6cc5540d411e32c3cc7ced3017742188d144
Author: Richard T Bonhomme <tincantech@protonmail.com>
Date:   Sun Nov 20 13:07:37 2022 +0000

    Minor refactor: escape_hazard()

    Remove development code. Improve text.

    Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-11-20 13:37:47 +00:00
Richard T Bonhomme
43d7648168
Option --subca-len - Allow value to be 0 (zero)
Squashed commit of the following:

commit 3a5e7539db93b88a9db8b2fb9fc6520870f337ac
Merge: 1a46e32 3d9fa5e
Author: Richard T Bonhomme <tincantech@protonmail.com>
Date:   Sun Nov 20 13:31:57 2022 +0000

    Merge branch 'path-len-zero' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-path-len-zero

    Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>

commit 3d9fa5e955f0ed517c63bb8c35e6fde180af8b6a
Author: Richard T Bonhomme <tincantech@protonmail.com>
Date:   Sun Nov 20 00:30:59 2022 +0000

    Option --subca-len - Allow value to be 0 (zero)

    For an intermediate CA certificate, Path length of zero (0) is valid.
    Therefore, allow the character '0' as a valid numeric input for EasyRSA
    option --subca-len=<N>

    This method allows character zero (0) ONLY, as a numeric input
    for options which accept zero as a value.

    Add comment: # Reset per pass flags

    Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-11-20 13:32:49 +00:00
Richard T Bonhomme
1a46e32454
Expand check for --keep-tmp value to an existing file of any type
Squashed commit of the following:

commit aecf6e63780d9aec8b31b61aff0704f45c9598c9
Merge: 85db316 244c059
Author: Richard T Bonhomme <tincantech@protonmail.com>
Date:   Sun Nov 20 13:28:12 2022 +0000

    Merge branch 'improve-keep-tmp' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-improve-keep-tmp

    Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>

commit 244c05968e76d1fa7673202e1623cb252083bc66
Author: Richard T Bonhomme <tincantech@protonmail.com>
Date:   Thu Nov 17 02:13:40 2022 +0000

    Expand check for --keep-tmp value to an existing file of any type

    Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-11-20 13:29:16 +00:00
Richard T Bonhomme
85db316606
Merge branch 'TinCanTech-fix-set_pass'
EasyRSA version 3.1.x only.

Summary of changes:

1. Introduce EasyRSA command 'set-pass'.

   Use SSL command 'pkey' to set passwords on all private key files.
   SSL command 'pkey' supports all EasyRSA croptoraphy settings.

   This replaces "Leacy" commands 'set-rsa-pass' and 'set-ecpass'.
   (These commands and their original code are retained for compatibility)

2. Remove the use of EasyRSA variable $no_password from legacy commands.

   This bug was caused by commit: 9b4bd19545ebc7faf0e281483ddb53748c40eb07

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-11-13 17:20:33 +00:00
Richard T Bonhomme
824849bce7
Merge branch 'fix-set_pass' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-fix-set_pass
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-11-13 17:19:41 +00:00
Richard T Bonhomme
1aae9b36fd
set_pass_legacy(): Remove $no_password "-nodes"
Closes: #765

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-11-11 18:37:47 +00:00
Richard T Bonhomme
d0019deb25
Current 'set-X-pass' commands do not support Edwards Curve cryptography.
Replace all 'set-X-pass' commands with single 'set-pass' command.

The new EasyRSA 'set-pass' command uses OpenSSL command 'pkey' to manipulate
private keys.  OpenSSL 'pkey' command supports all EasyRSA cryptography.

Retain compatibility with old commands.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-11-10 23:31:15 +00:00
Richard T Bonhomme
00e93d0abd
Require unique random serial number for certificate or fail
Squashed commit of the following:

commit 7bdc3cdfbf4ac11dc5ff6377b1b32306fc50bc66
Merge: 320a324 7fa4ec9
Author: Richard T Bonhomme <tincantech@protonmail.com>
Date:   Thu Nov 10 19:41:31 2022 +0000

    Merge branch 'fix-random-cert-serial' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-fix-random-cert-serial

    Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>

commit 7fa4ec9e3155f8b54648226397ef73f9086779d1
Author: Richard T Bonhomme <tincantech@protonmail.com>
Date:   Thu Nov 10 19:27:37 2022 +0000

    Require unique random serial number for certificate or fail

    This only effects Random certificate serial numbers: EASYRSA_RAND_SN
    (EASYRSA_RAND_SN is the Easy-RSA default mode)

    Previously, no matter if a _unique_ random serial number was generated,
    sign_req() would always use the last random number generated, as serial
    number for the new certificate.

    This behaviour also allowed _complete failure_ of the SSL serial number
    check to pass without error.

    This change allows signing a request to succeed ONLY when a unique serial
    number has been generated and validated.

    A failure of the SSL CA unique serial number check will NOT be ignored.

    Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-11-10 20:41:55 +00:00
Richard T Bonhomme
320a324965
New function: easyrsa-random() - Generate random hexadecimal data
Squashed commit of the following:

commit cb68324306febcddf7ef03fe56fc1eddf06e7db7
Merge: 82483f1 2199d0c
Author: Richard T Bonhomme <tincantech@protonmail.com>
Date:   Wed Nov 9 21:19:41 2022 +0000

    Merge branch 'f-easyrsa_random' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-f-easyrsa_random

    Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>

commit 2199d0c323e506df436a335375be9115a12d6b7f
Author: Richard T Bonhomme <tincantech@protonmail.com>
Date:   Wed Nov 9 21:05:17 2022 +0000

    Minor improvements to temp-session and temp-file

    Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>

commit aa15b74722632ecab14c07ba9f2158d121e55d4f
Author: Richard T Bonhomme <tincantech@protonmail.com>
Date:   Wed Nov 9 20:35:43 2022 +0000

    New function: easyrsa-random() - Generate random hexadecimal data

    Replace the various random requirements with this new function.

    Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-11-09 21:21:05 +00:00