Commit Graph
835 Commits
Author SHA1 Message Date
Richard T Bonhomme 95f4b67703 gen-crl: Minor improvements
Add EASYRSA_CRL_DAYS to command to generate a new CRL.
Although this is taken care of in the SSL config file,
it is easier to understand by having the code incuded
in the script.

Honor batch mode and over write an existing CRL, with
out confirmation.  An out dated CRL is of little value
and the user has specified batch mode, so honor it.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-02-25 14:56:09 +00:00
Richard T Bonhomme 8944eae7ac Use set_var to correctly assign EASYRSA_REQ_SERIAL
This configures EASYRSA_REQ_SERIAL for use in the SSL config file.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-02-23 13:09:07 +00:00
Richard T Bonhomme 04ee3b0977 Merge branch 'fix-offset-use-enddate' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-fix-offset-use-enddate
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-02-21 22:15:40 +00:00
Richard T Bonhomme 06fed95730 sign-req: Use either SSL option -days OR -startdate/-enddate
Using --fix-offset will not use -days, only -statdate/-enddate.

Options -startdate/-enddate are absolute dates, not counted from
today by OpenSSL, for any reason.

Fixes some unrelated warnings about incomplete SSL config file,
when using --fix-offset.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-02-19 22:10:26 +00:00
Richard T Bonhomme 2eda52061b sign-req: Only create a random serial number file when expected
When EASYRSA_RAND_SN="no", the file pki/serial file is not meant to
be updated by easyrsa. OpenSSL manages the file itself.

Move the code to write the file pki/serial with a random number,
inside the if condition for EASYRSA_RAND_SN, so the file is only
written to by easyrsa, when a random serial number is expected.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-02-19 21:37:30 +00:00
Richard T Bonhomme 88557aae8c build_ca: Initialise get_passphrase() correctly
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-02-12 02:37:34 +00:00
Richard T Bonhomme 2dd2767922 build-ca: Deliberately remove manual password in temp-file
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-02-11 23:11:43 +00:00
Richard T Bonhomme 9d21db8629 Merge branch 'set_var-v2' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-set_var-v2
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-02-11 21:54:04 +00:00
Richard T Bonhomme 8510681747 Merge branch 'cleanup-stty-echo' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-cleanup-stty-echo
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-02-11 21:42:07 +00:00
Richard T Bonhomme 1dc5c265ac Merge branch 'easyrsa_mktemp-v2' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-easyrsa_mktemp-v2
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-02-11 21:27:32 +00:00
Richard T Bonhomme 35dd0d919c Remove unused variable EASYRSA_EC_DIR
This was used to define a temp-dir for a temp-file for EC params.

This was replaced by standard temp-file EASYRSA_ALGO_PARAMS.

The replacement was due to EasyRSA support for OpenSSL version 3,
where SSL command 'genpkey' replaced the previous commands.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-02-11 02:51:24 +00:00
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 d4a1caa394 Rename variable EASYRSA_TEMP_DIR_session to secured_session
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-02-09 01:21:55 +00:00
Richard T Bonhomme 9a4b98246b secure_session(): Wrap long lines
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-02-09 00:41:45 +00:00
Richard T Bonhomme f762627e2d easyrsa_mktemp(): Drop redundant test of temp-session existence
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-02-09 00:21:35 +00:00
Richard T Bonhomme 043448503f easyrsa_mktemp(): Correct logic for file creation
Each try is now aimed at creating a unique target file.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-02-09 00:20:28 +00:00
Richard T Bonhomme 8de04a1439 Move verify_ssl_lib() - Always verify SSL lib, for all commands
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-02-08 23:05:33 +00:00
Richard T Bonhomme e70c6363e6 cleanup(): Only enable terminal echo when it has been disabled
Only build-ca with a manually entered password disables terminal echo.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-02-08 18:04:14 +00:00
Richard T Bonhomme b52f6cbd8b easyrsa_mktemp(): Pre-assign empty value to temp-file name
Satisfy shellcheck SC2154, var is referenced but not assigned.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-02-07 23:32:48 +00:00
Richard T Bonhomme fba0cf1986 easyrsa_mktemp(): Use sequentially numbered temp-files
This drops use of SSL to generate randomly numbered files.
The temp-session is still randomly named.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-02-07 19:49:24 +00:00
Richard T Bonhomme c2b20731d5 Merge branch 'remove-debug' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-remove-debug
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-02-04 19:53:14 +00:00
Richard T Bonhomme 4ad288ef5b Merge branch 'remove-extra-output-lines' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-remove-extra-output-lines
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-02-04 19:49:05 +00:00
Richard T Bonhomme 84f6a3775c init-pki soft: Add crl.pem to file delete list
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-02-04 14:47:31 +00:00
Richard T Bonhomme 0d404360c5 show-ca: Remove undefined '$type' variable from output
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-02-04 14:33:45 +00:00
Richard T Bonhomme d1063e0ad0 Remove redundant separator lines
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-02-04 00:55:36 +00:00
Richard T Bonhomme 3b5ff50bf7 Remove ineffectual redirector
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-02-04 00:43:40 +00:00
Richard T Bonhomme d5c28f6ec2 Move calling show_host() to function die(), where it belongs
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-02-03 23:51:06 +00:00
Richard T Bonhomme 1f80065917 Remove debug symbols
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-02-03 00:02:50 +00:00
Richard T Bonhomme 50174317bc Wrap long lines: easyrsa_openssl(), sed command
Move the sed command to a function and wrap long lines.
New function: easyrsa_rewrite_ssl_config()

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-02-02 20:56:26 +00:00
Richard T Bonhomme 9a46aefc3c Merge branch 'aesthetics-build-ca-create-dirs-files' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-aesthetics-build-ca-create-dirs-files
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-01-26 19:39:36 +00:00
Richard T Bonhomme 9047c95850 build-ca: Minor code reformat (aesthetics)
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-01-26 00:37:26 +00:00
Richard T Bonhomme 9a8bf39b75 Rename safe_set_var() to force_set_var()
force_set_var() is intended to deliberately over-write all prior values.

This also drops an unnecessary 'eval'.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-01-25 03:53:20 +00:00
Richard T Bonhomme 81ab139ebb Remove hard-coded unit-test password from build-ca
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-01-24 16:05:02 +00:00
Richard T Bonhomme c4eeff9201 build-ca: Write 'unique_subject = no' to index.txt.attr file
EasyRSA version 3.1x 'renew' command requires this attribute.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-01-22 19:20:24 +00:00
Richard T Bonhomme 91bcabeaf0 build_ca(): Wrap long lines
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-01-21 23:59:27 +00:00
Richard T Bonhomme 00d7a69788 sign_req(): Wrap long lines, improve error messages and comments
Add extra check for successfully moving of temp-file to certificate.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-01-20 17:21:52 +00:00
Richard T Bonhomme e6aa6f6393 gen_dh(): Wrap long lines
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-01-20 16:23:04 +00:00
Richard T Bonhomme b3e4c638bf Re-order output messages and subsequent newlines for aesthetics
Remove unused EASYRSA_ININE, satisfy shellcheck.

Wrap long lines.

Minor improvements to comments and error messages.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-01-20 15:48:28 +00:00
Richard T Bonhomme ffd63b6cc4 Add 'verify-cert' command to current 'verify' command
This should have always been 'verify-cert' because it only verifies
to certificates. (Also change 'help' text)

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-01-19 02:14:39 +00:00
Richard T Bonhomme ae10aee413 Wrap long lines in "Main" function and verify_cert()
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-01-18 21:00:11 +00:00
Richard T Bonhomme 8afd07b20d Minor related improvements
safe_set_var(): Show offending input value in error output

Standardise similar functions:
* ssl_cert_serial()
* ssl_cert_not_before_date()
* ssl_cert_not_after_date

Wrap more long lines.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-01-15 23:01:21 +00:00
Richard T Bonhomme c83a26d8ac db_date_to_ff_date(): Return ff_date via safe_set_var()
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-01-15 22:13:32 +00:00
Richard T Bonhomme 587ba1aa41 ff_date_to_cert_date(): Return cert_type_date via safe_set_var()
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-01-15 21:53:26 +00:00
Richard T Bonhomme 159aa15cd4 offset_days_to_cert_date(): Return cert_type_date via safe_set_var()
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-01-15 21:21:57 +00:00
Richard T Bonhomme b0f3d8bf90 cert_date_to_timestamp_s(): Return timestamp_s via safe_set_var()
This only effects status_expire(), show-expire.

Add error detection for 'date' usage.

Wrap long lines.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-01-15 20:38:51 +00:00
Richard T Bonhomme 7492097110 fixed_cert_dates(): Remove subshell
fixed_cert_dates(): Replace capturing subshell-output
by setting variables via safe_set_var().

Add error detection for 'date' usage.

Wrap long lines.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-01-15 19:01:09 +00:00
Richard T Bonhomme 8dc2064880 Option --fix-offset: Adjust off-by-one day
The current code calculates --fix-offset=1 as January 2nd.

This decreases the input value by one, which results in
--fix-offset=1 being January 1st.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-01-13 17:15:18 +00:00
Richard T Bonhomme 0699393324 Status Reports: Set 'LC_TIME=C.UTF-8', only used for reports
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-01-05 13:26:46 +00:00
Richard T Bonhomme b7f8d9f79a Global option '--passout' always take priority ONLY
Option '--passout' MUST take priority over '--nopass' and 'nopass'.
Otherwise, the private key is unintentionally created unencrypted.

Option '--passin' must NOT take priority.
Otherwise, it is not possible to automatically create an entity
key without a password, if the CA key is created with a password.

Initialisation: Wrap long lines

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-01-04 02:34:04 +00:00
Richard T Bonhomme e27ab41dad Refactor manual CA passphrase input
This is a personal preference only. No functional change.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-01-04 00:28:50 +00:00