1721 Commits

Author SHA1 Message Date
Richard T Bonhomme
8cdfbb2ffe
Minor cleanup of Unique random serial number control
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-07-14 21:43:29 +01:00
Richard T Bonhomme
3789aff3f5
Unset initial variables: Remove 'user_san_true', no longer used
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-07-14 15:56:03 +01:00
Richard T Bonhomme
fdb8e0e8df
Add show-req to the list of commands which do not require a CA
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-07-14 13:53:37 +01:00
Richard T Bonhomme
e5f3551710
sign-req: Major refactor
Move extension data preparation to before printing extension temp-file.
This allows the { extensions output command group } to always complete,
without error.

Consolidate create_x509_type_*() functions in one single function.
create_x509_type_easyrsa() remains as a separate function.
This file does not exist in x509-types directory. It is similar to the
COMMON x509-type; The details are the common extensions shared by x509
types: serverClient, server and client. Not suitable for x509-type ca.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-07-14 13:51:18 +01:00
Richard T Bonhomme
1d9370c00e
Merge branch 'TinCanTech-expose-sign-req-serial-check'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-07-13 17:08:17 +01:00
Richard T Bonhomme
a0ea8ac5c1
Merge branch 'expose-sign-req-serial-check' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-expose-sign-req-serial-check
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-07-13 17:07:37 +01:00
Richard T Bonhomme
b0a3ec9caf
check_serial_unique(): In batch mode, exit-with-error for non-unique
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-07-13 16:41:16 +01:00
Richard T Bonhomme
ef3e64f0a1
ChangeLog: Expose serial-check, display-dn, display-san and default-san
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-07-13 14:26:03 +01:00
Richard T Bonhomme
aa38037570
Expose display_dn, display_san and default_server_san to command line
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-07-13 12:44:39 +01:00
Richard T Bonhomme
cdad3a7844
Expose 'sign-req' unique, random serial number check to command line
Problem:

EasyRSA uses SSL CA command parameter '-serial $serial_number',
to check if a serial-number exists within the database.

The primary function of the SSL CA command parameter '-serial'
is to check if a certificate is Valid or has been Revoked.

EasyRSA abuses the SSL output to infer that a serial-number must
be unique because that output contains the text 'not present in db'.

SSL CA command parameter '-serial' ALWAYS returns an error,
reagrdless of what-ever check it does. Likely, an SSL bug.

As a step-in-the-right direction:

To ease this needless-headache, expose the unique, random
serial-number check to the command line.

This helps to understand what is going on under-the-hood.

The command 'sign-req' remains the same; except the unique, random
serial-number check is moved to a separate, stand-alone function,
which is also exposed to the command line for validation.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-07-12 23:15:35 +01:00
Richard T Bonhomme
1ebf4a2f9c
Merge branch 'TinCanTech-minor-changes'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-07-08 19:42:10 +01:00
Richard T Bonhomme
febe0fd304
Merge branch 'minor-changes' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-minor-changes
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-07-08 19:41:19 +01:00
Richard T Bonhomme
3cb911ef2a
Very minor changes to comments, help/msg text, wrap lines, code
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-07-08 19:04:10 +01:00
Richard T Bonhomme
99809bc3bb
Merge branch 'TinCanTech-easyrsa-exit-with-error'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-07-08 16:24:18 +01:00
Richard T Bonhomme
28d4cae3a4
Merge branch 'easyrsa-exit-with-error' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-easyrsa-exit-with-error
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-07-08 16:23:42 +01:00
Richard T Bonhomme
b16596f9ec
cleanup: Rename $easyrsa_error_exit to $easyrsa_exit_with_error
This reduces a tiny, unnecessary complexity for exiting with an error.

Functions which use the new variable to exit with error:
* verify_cert() and confirm().

Also, allow verify-cert to support --silent-ssl.

Add more verbose messages.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-07-08 16:13:08 +01:00
Richard T Bonhomme
80ac745925
Merge branch 'TinCanTech-316-verify-ssl-lib'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-07-05 23:01:02 +01:00
Richard T Bonhomme
44e2696e46
Merge branch '316-verify-ssl-lib' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-316-verify-ssl-lib
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-07-05 23:00:32 +01:00
Richard T Bonhomme
91bb2cf8e9
verify_ssl_lib(): Minor style improvements
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-07-05 22:26:40 +01:00
Richard T Bonhomme
ac0d826272
Add command show-host to command list that does not require a PKI
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-07-04 22:59:39 +01:00
Richard T Bonhomme
268e8f59fd
vars_setup() and init-pki() 'vars' management improvements
The actual changes made are:

* Remove $old_vars_true, no longer required.

* Change a test of $found_vars from any-string to specific number 1.
  Which then tests for only one vars file is found.

* If vars-file is created during init-pki then also set $vars to file-name.
  The change here is that $vars is now ALWAYS set for this condition.

* Always print the names of conflicting vars files.
  Helps debugging for users.

* Expand short-circuits to full 'if; then; else; fi'.

* Add more verbose messages
  Help for debugging.

The combined effect is to show the correct messages regarding vars file,
during default status, help, init-pki and standard further commands.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-07-04 20:39:23 +01:00
Richard T Bonhomme
5350d50e03
Format: Correct indentation
See: git diff -w

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-07-04 02:35:19 +01:00
Richard T Bonhomme
9f752bde7a
vars_setup(): For EASYRSA_NO_VARS set found_vars to zero
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-07-04 02:14:08 +01:00
Richard T Bonhomme
7ec58cd64c
Status: Use variable for ca.crt name and correct found_vars value
'ca.crt' was hard-coded to 'pki/ca.crt', instead use '$EASYRSA_PKI/ca.crt'

Status incorrectly warns that there are multiple, conflicting vars files,
when vars is user-defined. Set '$found_vars' to 1, when vars is user-defined.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-07-04 01:56:18 +01:00
Richard T Bonhomme
1135efc148
Merge branch 'TinCanTech-expand-default-status'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-07-04 00:16:27 +01:00
Richard T Bonhomme
2edec49954
Merge branch 'expand-default-status' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-expand-default-status
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-07-04 00:15:47 +01:00
Richard T Bonhomme
8d5867a54f
ChangeLog: Expand default status to include vars-file and CA status
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-07-03 23:59:04 +01:00
Richard T Bonhomme
e2e2d1bfa1
Expand default status to include vars-file and CA status
For default command 'easyrsa', show the following:
* Show the location of vars-file.
* Show the status of the CA.
* If vars is not in the PKI then show the "Prefer pki/vars" warning.

Also, show the "Prefer pki/vars" warning for all commands except help.

Move the logic to show the "Prefer pki/vars" warning to the function.

Extensively, manually tested.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-07-03 23:32:28 +01:00
Richard T Bonhomme
5a0c7cd1f9
Merge branch 'TinCanTech-warn-no-vars'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-07-03 13:38:45 +01:00
Richard T Bonhomme
0a895027f0
Merge branch 'warn-no-vars' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-warn-no-vars
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-07-03 13:37:48 +01:00
Richard T Bonhomme
97b9a4c665
vars-file: Warn about EASYRSA_NO_VARS disabling vars-file use
Also, minor improvement to checking vars-file for 'export' and 'unset'.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-07-03 13:13:30 +01:00
Richard T Bonhomme
9872cc22c1
Merge branch 'TinCanTech-set_var-allow-empty'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-07-03 02:16:07 +01:00
Richard T Bonhomme
890780116a
Merge branch 'set_var-allow-empty' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-set_var-allow-empty
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-07-03 02:15:26 +01:00
Richard T Bonhomme
8e62fa28d7
set_var(): Allow empty input to return without error
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-07-03 02:04:18 +01:00
Richard T Bonhomme
002c84fff1
verify_working_env(): Simple improvements, no functional changes
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-07-03 01:32:27 +01:00
Richard T Bonhomme
3db8c50782
Prefer test for '-z' over '!'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-07-02 22:13:18 +01:00
Richard T Bonhomme
c5d698d169
Merge branch 'TinCanTech-post-315-refactor'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-07-02 21:43:44 +01:00
Richard T Bonhomme
a8567ba80d
Merge branch 'post-315-refactor' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-post-315-refactor
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-07-02 21:38:27 +01:00
Richard T Bonhomme
444444595e
Simplify requirements for PKI, CA and vars file
Prioritise $EASYRSA_NO_VARS above other vars file detection.

Rename $pki_is_required to $require_pki

Re-establish; Do not require PKI, CA or vars for command 'upgrade'.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-07-02 21:10:10 +01:00
Richard T Bonhomme
232f9f6b8d
verify_working_env(): Verify PKI and CA are initialised as required
This moves all PKI and CA initialisation requirements into verify_working_env().

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-07-02 19:03:18 +01:00
Richard T Bonhomme
fdb3b1a2b2
Merge branch 'TinCanTech-sign-req-preserve-dn'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-07-02 14:11:23 +01:00
Richard T Bonhomme
e89f4d7ace
Merge branch 'sign-req-preserve-dn' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-sign-req-preserve-dn
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-07-02 14:10:34 +01:00
Richard T Bonhomme
49fda49e25
cleanup(): Change die() to warn(), cleanup cannot use die()
Minor improvements to help and comments

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-07-01 22:05:45 +01:00
Richard T Bonhomme
d29183721f
sign-req: Allow the CSR DN-field order to be preserved
When signing a request, EasyRSA ALWAYS defaults to the CA defined
Distinguished Name field order, as defined by openssl-easyrsa.cnf
configuration file.

In the unlikely event that a CSR is received with a different DN-
field order, that order can be preserved for the signed certificate.

Command 'sign-req', now has a command option 'preserve' for this.

Additional:

Use of 'preserve = yes' in openssl-easyrsa.cnf has no effect for
EasyRSA.

Testing OpenSSL directly indicates that this option may have no effect
when used in OpenSSL default configuration file openssl.cnf

Also, OpenSSL documentation for command 'ca', option '-preserveDN'
does NOT infer that this option can be used in the configuration file.

None of which is important to EasyRSA because only foreign CSRs can
have a different DN-field order, so default behavior can remain.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-06-30 21:28:41 +01:00
Richard T Bonhomme
dfd12562dc
Introduce Easy-RSA error log-file - Used by easyrsa_mktemp
When commands executed in a subshell fail the error message is lost.

Easy-RSA error log provides a permanent temp-file to write those
error messages to and be displayed on completion of the script.

This first use of the log-file by easyrsa_mktemp(), will log errors
caused by requiring more than three (3) subshell temp-files.

Temp-files created during a subshell command do not update the
temp-file counter, so their name relies on a second, built-in
extension to the temp-file name. If this second extension exceeds
three (3) then a non-fatal warning is logged to the error log-file.

Other functions, which are executed in subshells, will use the error
log-file in follow up patches, as required.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-06-26 12:47:53 +01:00
Richard T Bonhomme
f0aa171373
Introduce and use 'user_error()'
Replace use of die(), which is very noisy, with user_error(),
which simply outputs the error message and EasyRSA Version.

Use of user_error() is specific to input and file errors,
caused by invalid user input.

Internal errors continue to use die().

Other associated improvements to output.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-06-20 14:19:53 +01:00
Richard T Bonhomme
a4fb7f0528
sign-req: Minor improvements; Remove function-end 'return 0'
Remove fucntion-end 'retrun 0' because it masks unexpected errors.

'if; then; else; fi;' wrap SSL call.

Minor improvements.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-06-20 00:21:47 +01:00
Richard T Bonhomme
71bedfd554
Brace '{}' delimit variable names in long assignment strings
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-06-19 20:48:37 +01:00
Richard T Bonhomme
c004c89034
Rename variable: duplicate_cert_by_serial -> dup_cert_by_serial
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-06-19 20:28:17 +01:00
Richard T Bonhomme
d7aa07bc7f
User level output, general improvements
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-06-18 00:42:13 +01:00