446 Commits

Author SHA1 Message Date
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
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
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
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
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
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
Richard T Bonhomme
ccec36d3ea
Fold vars_source_check() back into verify_pki_init()
vars_source_check() is ONLY used by verify_pki_init(),
remove the extra function.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-08 21:32:12 +01:00
Richard T Bonhomme
1e7fb8243a
Silence cleanup()
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-08 20:33:25 +01:00
Richard T Bonhomme
29eaa061c2
Simplify detecting Windows
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-08 20:14:46 +01:00
Richard T Bonhomme
1844ec10af
Remove old comment for upgrade function
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-08 20:02:30 +01:00
Richard T Bonhomme
0db21c3dd4
Detect Windows and Git-for-Windows bash
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-08 19:47:27 +01:00
Richard T Bonhomme
b4ab1713c1
Remove all use of single quote (') from vars.example
A step toward a solution to #364

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-08 02:11:17 +01:00
Richard T Bonhomme
fe47eba2c0
Style improvements to vars_setup()
Make detecting all vars files more simple and robust.
Improve warning and error messages.

Favour PKI/vars, wiith bias.

* Minor changes to output format for warn() and notice()

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-07 22:09:50 +01:00
Richard T Bonhomme
75bc3d1ed5
Do not require/use Extended Regular Expression
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-07 18:02:31 +01:00
Richard T Bonhomme
48eee21d2a
Disallow use of single quote (') in vars file
Using single quotes in the vars file does not work:
* Either the vars file syntax is corrupted by an unescaped single quote.
* Or the SSL library will drop the single quote from the signed certificate.

Changes:
* Sanitize vars.example - Remove all single quotes.
* Search vars for single quote before sourcing it.

Closes: #34

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-07 17:18:41 +01:00
Richard T Bonhomme
7ae3ffd7d3
Remove left-over cruft
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-07 03:04:12 +01:00
Richard T Bonhomme
15386d4ee3
Improve shellcheck 2086 'Unquoted expansions' problem
Easy-RSA uses unquoted expansion.

Each instance of SC2086 has been vetted, accepted and ignored.

shellcheck will still find new exceptions.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-07 02:03:00 +01:00
Richard T Bonhomme
cb686a8be4
Simplify finding a vars file
1. Name All supported vars files
2. Search for each supported vars file
3. Only allow One (or None) supported vars file to exist.
4. Prefer PKI/vars file.
5. Warn for All other deprecated vars files, if they exist.
6. Warn for NO vars file found and prefer PKI/vars.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-06 23:49:11 +01:00
Richard T Bonhomme
223237ab7f
Only assign a value to $vars if a 'vars' file is found
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-06 22:59:23 +01:00
Richard T Bonhomme
57487a3406
Assign 'vars' correctly - set_var() is not suitable
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-06 22:22:15 +01:00
Richard T Bonhomme
7d1b00813c
Final improvements to vars_setup()
New standards introduced:
* Use '-e' to test for existence not '-f' file.
* Only use '-z' not '-n', more visually distinct.

Minor code improvement: Use 'if command' to test for success.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-06 19:42:34 +01:00
Richard T Bonhomme
3c216e8208
Tidy up commit cf6d9efcea7cc64a46118b680edd17d7367a9b84
Tidy up comments.
Silence spurious warning about 'vars not found'.
Only show which vars are found if more than one exists.
Minor code improvements.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-06 18:33:28 +01:00
Richard T Bonhomme
bd7f47ee61 Merge branch 'new_vars_setup' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-new_vars_setup 2022-04-05 23:19:47 +01:00
Richard T Bonhomme
4809babe23
Merge branch 'opt-silent' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-opt-silent
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-05 22:58:00 +01:00
Richard T Bonhomme
917b1dd25b Merge branch 'shellcheck' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-shellcheck 2022-04-05 22:45:47 +01:00
Richard T Bonhomme
72dc76c062
Merge branch 'TinCanTech-copy-x509-types-ca'
Added one newline to terminate the shellcheck directive above.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-05 22:30:06 +01:00
Richard T Bonhomme
283d4f7fd2 Merge branch 'copy-x509-types-ca' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-copy-x509-types-ca 2022-04-05 22:25:02 +01:00
Richard T Bonhomme
75021037ee
Remove inline file for revoke and renew
If an inline file is found that matches the certificate being revoked
or renewed then it will be removed, pending standard confirmation.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-05 18:18:54 +01:00
Richard T Bonhomme
4ec775e4a8
Merge branch 'fix-gen-req-cn' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-fix-gen-req-cn
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-05 16:49:13 +01:00
Richard T Bonhomme
a5669ed574
Insert missing '$'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-05 16:29:32 +01:00
Richard T Bonhomme
c345d0b7b8
Minor formatting correction
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-05 16:24:14 +01:00
Richard T Bonhomme
4d5a5d4a7b
Introduce new vars_setup() regime
vars_setup() now ignores some setup when this is 'init-pki'.
* Do not set anything which requires a PKI.

Remove some undocumented commands, which are known to break Windows.

Find 'vars' in preferred locations and only allow ONE instance.
* Probably a breaking change but only where things are already broken.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-05 01:27:17 +01:00
Richard T Bonhomme
393a510cf4
shellcheck recommendations (Ongoing)
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-04 00:52:38 +01:00
Richard T Bonhomme
6f138abb5b
Allow build_ca() to accept OpenSSL '-addext' as raw data
Set env:var:
EASYRSA_EXTRA_EXTS="-addext foo,a:b -addext bah,c:d -addext baz e:f,g"

The value of EASYRSA_EXTRA_EXTS is passed as-is to the SSL command.

Creating a CA does not allow for an arbitrary extensions file, therefore
extensions must be added via the config file (#526) or via SSL Library
option '-addext' (Can be specified to SSL multiple times).

Option '-addext' is allowed to be specified multiple times to SSL,
therefore, this string must be syntactically correct for SSL not EasyRSA.

Finally, rename EASYRSA_EXTRA_EXTS to EASYRSA_CA_EXTRA_EXTS to avoid
triggering EASYRSA_EXTRA_EXTS code buried inside of easyrsa_openssl().

Closes: #54

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-03 03:13:39 +01:00
Richard T Bonhomme
7227adcca2
Rigorously quote all use of "$EASYRSA_BATCH"
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-03 02:31:55 +01:00
Richard T Bonhomme
bce4dadc43
Use x509-types 'ca' and COMMON when building a CA
To sign a request, easyrsa uses 'openssl ca', which does support -extfile.

To create a CA, easyrsa uses 'openssl req', which does not support -extfile.

Therefore, the x509-types 'ca' and COMMON files cannot be specified using
-extfile to create a CA. Instead, they must be included within the SSL
config file, which 'openssl req' does support.

Using the same awk script from gen_req(), with New Token '#%X509_TYPES%',
the x509-types files 'ca' and COMMON are inserted into the SSL config file.

Closes: #525

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-03 00:10:09 +01:00
Richard T Bonhomme
a52d6c5a71
Make gen_req() Always use EASYRSA_REQ_CN as intended
All requests now have the specified commonName <FILE_NAME_BASE>

Changes:

* Separate EASYRSA_BATCH from internal SSL -batch option.
  This makes the code easier to understand.

* If both EASYRSA_BATCH and openssl_batch are unset then full
  inter-active mode is enabled.  The user can verify the input.

  Otherwise SSL interactive is disabled and no user interaction
  is required.

  In either case, all DN fields are fully populated, depending on
  EASYRSA_DN mode ('org' or 'cn_only').

Closes: #456

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-02 15:42:56 +01:00
Richard T Bonhomme
ec1bac96cb
Separate silent-mode from batch-mode - Respect batch-mode
Introduce EASYRSA_SILENT to enhance the use of EASYRSA_BATCH.
Effected functions: warn()

The change in behaviour is that warn() can ONLY be silenced by
option --silent.  Batch-mode is still respected but silence is not.

For scripts which rely on EasyRSA, if they use option --batch then
the change to restore prevous bevaviour is to use option --sbatch.
Otherwise, export EASYRSA_SILENT=1.

This is a minimal change that preserves batch-mode functionality but
also heeds Warnings, unless NEW option --sbatch is specifcally used.

Warnings should not be silenced by batch-mode.

Closes: #512

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-01 20:53:39 +01:00
Wharf in Ships Clothing
b25d74e6b7
Remove obsolete function copy_data_to_pki()
Signed-off-by: Wharf in Ships Clothing <wiscii@protonmail.com>
2022-04-01 16:03:52 +01:00
Richard T Bonhomme
0d29396070
General formatting corrections (NFC)
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-03-31 23:00:47 +01:00
Richard T Bonhomme
14a29f9fca
Merge branch 'Antagonym-soft-reset'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-03-31 22:50:43 +01:00
Richard T Bonhomme
24a2b4fa77
Merge branch 'soft-reset' of ssh://github.com/Antagonym/easy-rsa into Antagonym-soft-reset
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-03-31 22:00:25 +01:00
Richard T Bonhomme
6759e87dd9
Merge branch 'patch-1' of ssh://github.com/pacija/easy-rsa into pacija-patch-1
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-03-31 19:54:22 +01:00