1073 Commits

Author SHA1 Message Date
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
Richard T Bonhomme
993c378dac
Improve shellcheck usage by adding descriptive comments
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-19 15:18:12 +01:00
Richard T Bonhomme
2fe73a5040
Disable shellcheck 2086 when building CA cert/key pair
SC2086 - Double quote to prevent globbing and word splitting.

It is not suitable to quote $opts and $EASYRSA_EXTRA_EXTS
because then they are passed to SSL as a single option
with spaces, which is not the intended use.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-19 13:17:45 +01:00
Richard T Bonhomme
1b8a1122d3
Remove CA specific EASYRSA_CA_EXTRA_EXTS, not required.
* EASYRSA_CA_EXTRA_EXTS: Created to avoid clash with EASYRSA_EXTRA_EXTS

EASYRSA_CA_EXTRA_EXTS was an interim hack to avoid triggering a code
injection buried deep inside easyrsa_openssl(), when building a CA.
Fixed by Commit: 057be57825616199d125dfffbc5abfa9efaae792

Remove EASYRSA_CA_EXTRA_EXTS:
Created by Commit: 6f138abb5b091fe7715fa7c8c6369d7704b6f177

The result is for all extra extensions to be subject to the same code.
The CA no longer has to dodge the code injection.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-18 23:58:56 +01:00
Richard T Bonhomme
7c2dd54214
Terminate if temporary directory does not exist + typ0 [shellcheck]
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-18 22:07:47 +01:00
Richard T Bonhomme
f503a22cc7
Include option '--tmp-dir' to define the temporary directory
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-18 20:50:09 +01:00
Richard T Bonhomme
c42364ab32
Create temporary session directory for 'init-pki' as required
'init-pki' is run in two different states:

* Without a pre-existing PKI
* With a pre-existing PKI

This causes 'init-pki' temporary session directory status to be undefined.

If a PKI does exist then a "session" directory will exist.
If a PKI does not exist then a "session" will not be defined and a directory
will not exist.

Additionally, a 'soft' init-pki leaves the current "session" directory
completely intact.

Resolve this by Always deleting the old "session" and creating a new "session".
* Only 'init-pki' is allowed to do this.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-18 01:13:29 +01:00
Richard T Bonhomme
a289da60cf
Add hosts OS details to fatal error messages
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-17 13:55:07 +01:00
Richard T Bonhomme
01faf60e80
Merge branch 'TinCanTech-secure-session'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-17 13:39:11 +01:00
Richard T Bonhomme
368db7fc5c
Replace non-POSIX mktemp with POSIX mkdir and mv
mktemp was used to create temp-files but it is not POSIX and
the version shipped for Windows has known bugs.

Replace mktemp with atomic directory and file creation using mkdir
and mv, both of which are atomic.

The temporary directory "session" directory is created using mkdir
with a 32bit random number for the name.

eg: /tmp/easyrsa-temp/b01dface

The temporary file is created by moving another file into the place
of the temp-file, with a 32bit random number for the name.

eg: /tmp/easyrsa-temp/b01dface/c01dface

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-16 16:57:27 +01:00
Richard T Bonhomme
d827747600
Use easyrsa_openssl() wrapper for +verify_curve_ec()
Plus some minor formatting tweaks.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-16 16:46:37 +01:00
Richard T Bonhomme
4fc2696a67
Minor improvement to verify_curve_ec()
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-13 15:13:53 +01:00
Richard T Bonhomme
d7b5c98d69
Fix version information and avoid warnings for version and help
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-13 15:09:41 +01:00
Richard T Bonhomme
f4af868cbc
Minor improvement to verify_curve_ed()
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-13 12:47:18 +01:00
Richard T Bonhomme
7e73368a28
Flip short-circuit to avoid having to capture unnecessary error
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-13 12:36:02 +01:00
Richard T Bonhomme
d29aee3e1b
Output only - Standardise message use of notice(), warn() and die
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-13 12:28:56 +01:00
Richard T Bonhomme
8c606c532c
Merge branch 'TinCanTech-build-ca-quote-temp-pass-file-name'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-13 12:10:12 +01:00
Richard T Bonhomme
41c0248de6
Merge branch 'build-ca-quote-temp-pass-file-name' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-build-ca-quote-temp-pass-file-name
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-13 11:06:06 +01:00
Richard T Bonhomme
b68ffc28d7
ChangeLog: Announce new maintenance
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-13 03:22:45 +01:00
Richard T Bonhomme
1d6a5f803e
Set default EASYRSA_PKI to $EASYRSA/pki and some minor improvements
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-13 02:37:50 +01:00
Richard T Bonhomme
29a8a48638
build_ca() - Quote temporary password file "$out_key_pass_tmp"
The problem:

* crypto_opts="$crypto_opts -pass file:$out_key_pass_tmp"

This cannot be reliably expanded and passed as an unquoted option.
This is due to the unquoted file name $out_key_pass_tmp.

The solution:

* Do not polute $crypto_opts with password related options.
* Specifiy the correct '-pass/-passin/-passout file:xx' for each command.

This allows "$out_key_pass_tmp" to be corrrectly quoted.

Also, apply the same quoting technique to $crypto_opts.

Minor alterations to OpenSSL command line layout, readability.

Comment out the replaced code, not removed. For comparison.
(Follow-up patch will remove the comments)

Full unit-tests completed throughout development.
Manually tested multiple password protected PKIs.
OpenSSL 1.1.1 and 3.0.2

Not tested:
* OpenSSL options: -pass/-passin-/passout file:"$out_key_pass_tmp"

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-13 01:00:08 +01:00
Richard T Bonhomme
c18d7f2bf0
Improve informational output: 'init-pki' completed
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-12 20:50:55 +01:00
Richard T Bonhomme
079aedda73
Merge branch 'TinCanTech-easyrsa_openssl-style'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-12 19:21:50 +01:00
Richard T Bonhomme
e1dfacef6b
Merge branch 'easyrsa_openssl-style' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-easyrsa_openssl-style
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-12 19:18:18 +01:00
Richard T Bonhomme
3dfd57b760
Optimize 'vars_in_pki' - Allow further checks on PKI/vars
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-12 19:09:48 +01:00
Richard T Bonhomme
6e2d139177
Add helpful Warnings to promote preferred use of PKI/vars
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-12 18:35:47 +01:00
Richard T Bonhomme
17ebec2a3e
Merge branch 'TinCanTech-vars-single-quote'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-12 15:40:20 +01:00
Richard T Bonhomme
bff4a486e2
Merge branch 'vars-single-quote' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-vars-single-quote
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-12 15:37:41 +01:00
Richard T Bonhomme
7d5185f52c
easyrsa_openssl() - Minor syle changes
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-12 14:01:42 +01:00
Richard T Bonhomme
de7735115c
Only warn if 'vars' is in PKI
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-11 23:32:17 +01:00
Richard T Bonhomme
4c4efbd6ae
Change Error to Warning: Make (') in vars-file non-fatal
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-11 23:08:36 +01:00
Richard T Bonhomme
e30bfd3773
Unit test: Improve output
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-11 21:58:11 +01:00
Richard T Bonhomme
3160cac48f
Merge branch 'TinCanTech-easyrsa_openssl'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-11 21:54:19 +01:00
Richard T Bonhomme
7b4272f34d Merge branch 'easyrsa_openssl' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-easyrsa_openssl 2022-04-11 21:52:28 +01:00
Richard T Bonhomme
6745e0e58a
Merge branch 'TinCanTech-win-git-bash'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-11 21:21:42 +01:00
Richard T Bonhomme
f0a3047cec Merge branch 'win-git-bash' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-win-git-bash 2022-04-11 21:19:50 +01:00
Richard T Bonhomme
540c6ff5af
Unit test: shellcheck easyrsa-unit-tests.sh
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-11 21:16:25 +01:00
Richard T Bonhomme
3e24a76d7e
Allow saving test data and improve log output
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-11 19:38:44 +01:00
Richard T Bonhomme
1aeddd9fcf
Unit tests: Enable shellcheck and OpenSSL v3 (*nix only)
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-11 16:13:04 +01:00
Richard T Bonhomme
50850f5ff3
op-test.sh - Set System SSL for Windows
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-11 16:07:26 +01:00
Richard T Bonhomme
ea666d5b97
op-test.sh - exit with correct status
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-11 16:00:45 +01:00
Richard T Bonhomme
f79b66aba7
op-test.sh - Total rewrite
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-11 15:36:30 +01:00
Richard T Bonhomme
adc03b5a5d
Enable unit test with OpenSSL version 3 on REMOTE-CI
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-09 22:40:22 +01:00
Richard T Bonhomme
a482caa79b
Unit test - Temporarily disable shellcheck
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-09 22:00:03 +01:00
Richard T Bonhomme
538f3eada6
Enable OpenSSL version 3 unit tests
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-09 21:44:51 +01:00
Richard T Bonhomme
4b75783375
Upgrade Linux based unit test to OpenSSL 3.0.2
- 15 Mar 2022 (Library: OpenSSL 3.0.2 15 Mar 2022)

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-09 21:40:44 +01:00
Richard T Bonhomme
484bc56acc
Remove redundant Create $EASYRSA_SSL_CONF
The config file is unambiguously and previously created by
install_data_to_pki().

The config file location is exported in the previous command.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-09 19:28:18 +01:00
Richard T Bonhomme
057be57825
Remove EASYRSA_EXTRA_EXTS code injection inside 'sed' script.
This code injection 'attempted' to insert a temp-file created with
EASYRSA_EXTRA_EXTS data. The insertion would take place at the awk
script marker "^#%EXTRA_EXTS%". However, this marker has already
been replaced by gen_req(), thus the condition to insert the code
was never met and the code injection has never taken place.

Testing this, I created a new marker for this injection to key from
and, due to the file-name variable not having been quoted, the test
fails when the file name has a space in it.

General tidy-up of easyrsa_openssl()

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-09 17:52:42 +01:00