953 Commits

Author SHA1 Message Date
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: 59dc15ac517534a1c18f36cec70d990f9b3eb464
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
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