Commit Graph
791 Commits
Author SHA1 Message Date
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
Richard T Bonhomme 866557a589 install_data_to_pki(): Wrap long lines, no functional changes
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-01-03 20:23:50 +00:00
Richard T Bonhomme 5d59605365 init-pki: Add new inline directory (Wrap long lines)
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-01-03 19:19:30 +00:00
Richard T Bonhomme ae0020acdc Create new 'inline' directory as required
Require creation during init-pki, renew and rebuild.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-01-03 16:08:16 +00:00
Richard T Bonhomme a7f5044c0d Add new inline file to command 'rebuild' processes
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-01-02 22:01:27 +00:00
Richard T Bonhomme 0072f5171c Add new inline file to command 'renew' processes
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-01-02 21:38:39 +00:00
Richard T Bonhomme ef9b3b8192 Add new inline file to command 'revoke' processes
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-01-02 20:28:44 +00:00
Richard T Bonhomme f5da984c49 build-full: Always enable inline file creation
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-01-02 20:07:36 +00:00
Richard T Bonhomme 5f85068558 init-pki(): Introduce second warning before HARD removal
Only if a PKI currently exists, add a second confirmation to promote
the use of 'init-pki soft'.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-01-01 22:56:51 +00:00
Richard T Bonhomme b56357e1bc verify_cert(): Support global --batch mode
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-01-01 19:45:29 +00:00
Richard T Bonhomme 4c0c02217f Merge branch 'cleanup-exit-number-only' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-cleanup-exit-number-only
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-01-01 18:24:20 +00:00
Richard T Bonhomme 96b96c18c7 Merge branch 'default-ed-curve' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-default-ed-curve
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2023-01-01 18:19:57 +00:00
Richard T Bonhomme 7afb20ad1a cleanup(): Exit with numeric error-code only
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-28 23:15:39 +00:00
Richard T Bonhomme 3050d59f60 fixed_cert_dates(): Remove unused variable 'today_n'
Originally used to calculate roll-back by one year, also removed.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-28 17:51:27 +00:00
Richard T Bonhomme 48a74fbca0 Default settings: Make default Edwards curve ED25519
Perform hierarchial decision for elliptic curve name.

Default curves per algorithm:
* 'ec' Elliptic curve name 'secp384r1' (Unchanged)
* 'ed' Edwards curve name 'ed25519' (Changed)

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-28 17:15:40 +00:00
Richard T Bonhomme 97cea4157d Merge branch 'allow-post-date-fix-offset' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-allow-post-date-fix-offset
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-22 22:18:52 +00:00
Richard T Bonhomme 4b3458b979 build-ca: Change FATAL error to warning for old openssl-easyrsa.cnf
This will only effect a CA built with custom EASYRSA_EXTRA_EXTS;
The solution being, to use the correct 'openssl-easyrsa.cnf'.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-21 13:49:54 +00:00
Richard T Bonhomme a320b291d6 Merge branch 'formalise-cleanup-exit' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-formalise-cleanup-exit
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-20 20:28:53 +00:00
Richard T Bonhomme 5ea6177338 Wrap more long lines
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-20 20:25:14 +00:00
Richard T Bonhomme fc4bcb6184 cleanup(): General improvements - Create KNOWN error exit
Where errors are known, exit via 'Known' branch.
Allow preset error number to propagate.

Long line wrapping. Shorten associated variable names.

Move clearing traps to within cleanup().

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-20 20:06:26 +00:00
Richard T Bonhomme e4b02a1dcb Function safe_set_var(): Hard exit for unexpected errors
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-17 22:40:56 +00:00
Richard T Bonhomme 6e0a9c78c4 Wrap long lines
hide_read_pass()
get_passphrase()

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-17 22:38:12 +00:00
Richard T Bonhomme 1cf4cce432 Renew: wrap long lines in related functions
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-17 22:35:13 +00:00
Richard T Bonhomme a815f39847 Function renew_move(): Ignore non-essential file removal errors
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-17 22:27:39 +00:00
Richard T Bonhomme 4c8a4e8765 Command renew: Require CSR as input file and refactor verification
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-17 21:51:39 +00:00
Richard T Bonhomme b4dc2ad0ea Command renew: Process options correctly and minor improvements
Process options correctly:
* This removes an errant 'shift' when processing options.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-17 21:45:23 +00:00
Richard T Bonhomme 0ce126a289 build-ca: Error-exit on failure to write temp-CA-passphrase files
Also, prototype easyrsa_mktemp() errors.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-13 00:02:28 +00:00
Richard T Bonhomme 9a495f7bd3 build-ca: Use OpenSSL '-passout' with EasyRSA '--passout' correctly
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-12 21:22:44 +00:00
Richard T Bonhomme 0063de0d88 Allow default CA generation method to be unit-tested
If 'easyrsa' is being run by the unit-test then allow the default method
for 'build-ca' to be exercised.

The default 'easyrsa' method is to use temp-files, generated by EasyRSA,
to pass the CA passphrase, provided by the user, to the SSL command.

The normal 'unit-test' method to use a passphrase is to configure EasyRSA
ommand line options '--passin' and '--passout'.

The change made here is to simulate user-interaction and to supply a
default passphrase, as a user, to the SSL command.
To NOT use EasyRSA command line options to set any passphrase.
ONLY when being run by the unit-test.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-11 22:37:40 +00:00
Richard T Bonhomme 8ae6bca3dc Windows, build-ca: Add input password to re-open private key
Using OpenSSL 3.0.7, packaged by OpenVPN Windows installer, causes
EasyRSA command 'build-ca' to fail, because it does not have an input
password to re-open the private key, which is required to generate
the CA certificate.

Provide the user specified CA passphrase as input password for build-ca.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-11 22:29:35 +00:00
Richard T Bonhomme d3f4cb4d02 ssl_cert_not_after_date(): Use safe_set_var()
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-10 14:26:46 +00:00
Richard T Bonhomme ec184ca49e ssl_cert_not_before_date(): Use safe_set_var()
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-10 14:14:19 +00:00
Richard T Bonhomme 8f71f71d8e build-ca: Use safe_set_var()
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-10 13:29:56 +00:00
Richard T Bonhomme b578efcb50 New function safe_set_var(): Safe wrapper for set_var()
When using set_var() with a variable as in input for name of the variable,
use this wrapper to verify the input is suitable as a variable name.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-10 13:17:39 +00:00
Richard T Bonhomme 01ded61201 Wrap long lines for code close by to status report functions
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-09 22:48:11 +00:00
Richard T Bonhomme abad51a4f3 Status reports: Recognise Expired certificates
Command show-expire:
Improve report outut to show 'expired: <date>' for expired certificates.
Otherwise, show 'expires: <date>' for currently Valid certicates.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-09 22:26:58 +00:00
Richard T Bonhomme 3ce9272e3a easyrs_openssl(): Correct comment only
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-08 02:03:29 +00:00
Richard T Bonhomme 591924d631 Stop EASYRSA_DEBUG interfering with SSL output from subshells
Some commands must capture the SSL output via a subshell.
eg: ssl_cert_serial() and ssl_cert_not_before/after_date()

To use easyrsa_openssl() for these commands, EASYRSA_DEBUG must be disabled.
This patch unsets EASYRSA_DEBUG in the function subshells only.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-08 00:58:43 +00:00
Richard T Bonhomme 2396ac21a2 Merge branch 'reorder-easyrsa_openssl' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-reorder-easyrsa_openssl
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-08 00:50:48 +00:00
Richard T Bonhomme 8ede536206 Re-order easyrsa_openssl() temp-file assignment
Always assign the easyrsa_openssl() temp-file before escape_hazard().
In the event of failure, easyrsa_openssl() will try first.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-08 00:17:17 +00:00
Richard T Bonhomme 3c0d90799f ff_date_to_cert_date(): Correct the input format for busybox date
Also, correct alignment and indents with no functional change.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-07 23:15:04 +00:00
Richard T Bonhomme fc1951a9dd Allow --fix-offset to create post-dated certificates
Currently, --fix-offset does not allow creating post-dated cerificates.
Instead, it rolls the start date back by one year.

The reason for this behavior is that --fix-offest was only meant to fix
a day of the year but not which year.

This patch simply removes the check for a post-dated certificate, which
allows `not-before-date` to be set upto one year in the future.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-07 20:23:12 +00:00
Richard T Bonhomme 9266caaf33 verify_ssl_lib(): short-circuit overload check; un-indent by one tab
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-07 02:15:01 +00:00
Richard T Bonhomme c5d401651c Introduce OpenSSL only mode: No Safe SSL Config File
Global option '--no-safe-ssl' disables generating a safe SSL config file.

The default is to always generate a safe SSL config file.

Can be used by OpenSSL ONLY.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-05 20:44:28 +00:00
Richard T Bonhomme 4be21f8fd2 Merge branch 'always-use-easyrsa_openssl' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-always-use-easyrsa_openssl
PLUS: Minor changes to error meesage output only, no functional changes.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-12-04 20:33:31 +00:00