1134 Commits

Author SHA1 Message Date
Richard T Bonhomme
3cd149275d
Merge branch 'TinCanTech-renew-cleanup'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-08-06 16:24:24 +01:00
Richard T Bonhomme
8da0d2516d
Merge branch 'renew-cleanup' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-renew-cleanup
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-08-06 16:22:52 +01:00
Richard T Bonhomme
27bed349b5
Merge branch 'TinCanTech-renew-req'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-08-06 15:10:22 +01:00
Richard T Bonhomme
51aa8a88e7
Merge branch 'renew-req' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-renew-req
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-08-06 15:08:57 +01:00
Richard T Bonhomme
2ab7205131
Squashed commit - doc: Add 'ed' option to EASYRSA_ALGO
commit 37232a8a6677dcdd5be4b4f9d3f1c8241e214a49
Merge: bee93cf a3c9f0b
Author: Richard T Bonhomme <tincantech@protonmail.com>
Date:   Fri Aug 5 18:05:56 2022 +0100

    Merge branch 'doc-add-ed' of ssh://github.com/mnme/easy-rsa into mnme-doc-add-ed

    Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>

commit a3c9f0bb5b79fa9fffaaf65b109069035138788b
Author: Nicolas Jeker <n.jeker@gmx.net>
Date:   Thu Aug 20 11:31:32 2020 +0200

    doc: Add 'ed' option to EASYRSA_ALGO

    Related to #488

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-08-05 18:08:02 +01:00
Richard T Bonhomme
bee93cf869
Merge branch 'TinCanTech-up23-secure-session'
Note: This change only assigns the secure session variable,
it does not create the directory nor any files within it.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-07-30 12:34:08 +01:00
Richard T Bonhomme
4567091c1f
Upgrade-23: Assign a secure session for temporary directory
To create Easyrsa Safe SSL config file, a standard temporary
directory is required, which can only be created after a secure
session has been assigned.

Closes: #622

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-07-30 11:57:38 +01:00
Richard T Bonhomme
a46e33a019
Improve comments regarding 'verify_pki_init' (No functional change)
Also, verify use of verify_pki_init(), manually.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-06-26 01:10:24 +01:00
Richard T Bonhomme
ae584fae99
Add 'renew-req' to ChangeLog
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-06-25 16:54:01 +01:00
Richard T Bonhomme
6060015b39
Restore files when 'renew' fails during 'build_full()' phase
Because easyrsa uses die() on errors, functions which call other
functions may not receive a returned error code and, therefore,
a test for an error will not occur in the calling function.

If 'renew' fails in the build_full() phase then build_full(), gen_req()
or sign_req() will error out to die() and not return an error to 'renew'.
This leaves the files which are about to be renewed in the 'renewed'
sub-folder without replacement files in the PKI folders.

Set 'on_error_undo_renew_move=1' and call renew_restore_move() from
cleanup() when an error occurs during the build_full() phase of 'renew'.

Closes: #613

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-06-25 15:25:56 +01:00
Richard T Bonhomme
727cd69108
Introduce 'renew-req': Create new certificate request for an existing key
EasyRSA 'renew' does not renew a certificate, it builds a new cert/key pair.
This 'old' method thus causes the Entity Private Key to be 'leaked'.

'renew-req' allows the original Entity Private Key to remain ''secure''.

This is achieved by generating a new certificate request for the original
Entity Private Key, to be submitted for signing by the CA administrator.

Resolves: #609

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-06-25 13:51:42 +01:00
Richard T Bonhomme
e5ec1ab771
Document '--req-serial' - Update 'help' and ChangeLog
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-06-21 00:22:50 +01:00
Richard T Bonhomme
8135e762c4
Merge branch 'TinCanTech-org-serialNumber'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-06-20 23:38:57 +01:00
Richard T Bonhomme
47080028e3
Remove stray space characters
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-06-20 23:11:59 +01:00
Richard T Bonhomme
72a32a3288
Introduce 'serialNumber' field for DN (OID 2.5.4.5)
Add a *final* layer of granularity to X509 Distinguished Name.
Only used if --req-serial="<PRINTABLE>user data" is specified.

To minimize the noise to the user by this new field, change the way
that OpenSSL is called to build a CA: Always use '-batch' mode.

User visible change when building a CA:
* Instead of being prompted for each individual DN field, now the
  user is presented with a read-out of how the fields are currently
  set. There is now only a single confirmation that all fields are
  correct.
* If '--req-serial' is not used then 'serialNumber' is not displayed.

PRINTABLE: a-z,A-Z,0-9, -+/=.,?:()

Closes: OpenVPN#462 - The original proposal and prototype code.
Closes: OpenVPN#598 - Supersedes: Introduce 1.organizationalUnitName
Closes: OpenVPN#600 - Bugfix: Remove unused 'name' definition from SSL conf.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-06-20 21:46:11 +01:00
Richard T Bonhomme
c300f6043f
LibreSSL corrections: genpkey and no-password
Squashed commit of the following:

* easyrsa_openssl() - Disable 'genpkey -config' for LibreSSL
  Closes: #601

* Set '-nodes' for LibreSSL version 3 'no-password' mode
  Closes: #602

Minor corrections to indentation/comments.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-06-20 00:54:42 +01:00
Richard T Bonhomme
17df3b8220
Complete missing 'busybox date' commands
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-06-16 23:05:39 +01:00
Richard T Bonhomme
23558ae81d
Re-instate subshell for build_full() -> sign_req()
Subshell is required due to use of die() in sign_req().
Otherwise, on error sign_req() errors out without removing input files.

Revert part of commit: 15429df9fdd5c63c6e33dba141ff2e9a77ed0855

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-06-16 12:03:51 +01:00
Richard T Bonhomme
2bc89f7658
DEPRECATE(1) '--req-cn' - Change default certificate 'renew' to 90 days
Option '--renew-days=#', variable $EASYRSA_CERT_RENEW was used to enforce a
"grace" period, *outside of which* 'renew' was prohibited. Default: 30days.

This prohibition is no longer enforced:
* https://github.com/OpenVPN/easy-rsa/issues/593

Option '--renew-days=#' now represents the cut-off date for EasyRSA status
report 'show-expire'. This report *only* lists those certificates which will
expire within the given $EASYRSA_CERT_RENEW number of days 'from now'.

This also effects the command 'renewable'. (Only supports GNU 'date')

Updates to 'help options'.

(1) Official notice of "intention to deprecate" option: '--req-cn'

EasyRSA has *never* supported '--req-cn'.

For "type" server/client 'Build-$type-full' AlWAYS explicitly sets variable
EASYRSA_REQ_CN to $2 from the command line.  Always over-riding the option.

'gen-req' explicitly sets 'EASYRSA_REQ_CN="$1"'. Always over-riding ..

'sign-req' explicitly sets 'crt_out="$EASYRSA_PKI/issued/$2.crt"' .. ditto.

'build-ca' requires specific code review to understand.
Labeled as: "May have tried but gave up.."

This is *only* a notice of "intention to deprecate".

The main goal of the option '--req-cn' is to achieve a disconnect between
certificate 'commonName' verses the 'file-name' of the certificate.

Eg: file-name: mmjd0101.crt | commonName: "mass-murderer John Doe (#0101)"

There is "merit" to this functionality but then .. EasyRSA is Free-OSS.

"If You need this functionality then You should help provide it."

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-06-13 20:32:35 +01:00
Richard T Bonhomme
38189be360
Introduce 'show-host' - Deep diagnostic
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-06-11 11:57:41 +01:00
Richard T Bonhomme
a11ddefe5d
Correct 'date' for Darwin/*BSD: "${days}days" -> "${days}d"
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-06-11 11:15:40 +01:00
Richard T Bonhomme
8b806163be
Prioritise busybox 'date' in date functions and minor corrections
Where busybox is installed, use it even if a standard 'date' exists.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-06-11 10:59:26 +01:00
Richard T Bonhomme
9e3fe4791f
Remove unnecessary subshell from 'date' evaluation
If this 'date' is MacPorts then it will fall throught to:

  * This *is* the bottom-line, "date-wise": Ubuntu or busybox.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-06-11 02:08:02 +01:00
Richard T Bonhomme
8c1ac0c800
Re-introduce "fixed date" certificates
Use command option '--fix-offset=nnn' [nnn: 1 - 365] day number,
to set the date at which the certificate will become Valid.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-06-10 22:43:40 +01:00
Richard T Bonhomme
bf3c21273e
Improve debugging control
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-06-10 22:32:23 +01:00
Richard T Bonhomme
15429df9fd
Minor improvements: Debugging and sign_req()
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-06-10 21:36:14 +01:00
Richard T Bonhomme
53da18d96a
Prioritise 'trap' and 'detect_host()' over all other processing
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-06-10 20:14:11 +01:00
Richard T Bonhomme
7aa52b75f4
Do not delete PKCS files when using revoke_renewed()
When revoking a renewed certificate, do not delete PKCS files,
because they do not belong to the old certificate which was renewed.

Update warnings to reflect this change.

Add revocation "reason" to confirmation dialogues.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-06-08 16:26:34 +01:00
Richard T Bonhomme
4078523e60
Merge branch 'TinCanTech-replace-cert_dates'
Additional: Windows 'date.exe' is also supported.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-06-08 15:19:24 +01:00
Richard T Bonhomme
3342df6650
Merge branch 'replace-cert_dates' of ssh://github.com/TinCanTech/easy-rsa into TinCanTech-replace-cert_dates
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-06-08 15:16:38 +01:00
Richard T Bonhomme
72b84c489d
Merge branch 'TinCanTech-remove-renew-30day-grace'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-06-08 15:13:27 +01:00
Richard T Bonhomme
9fda11d04f
Replace the original cert_dates() function with extensible wrappers.
The original cert_dates(); was intended to restrict certificate renewal
to a fixed 30-day-window of the certificate expiry date.  This was an
unnecessary restriction. Removed-by: #594

The original cert_dates(); "gave rise to" the Easy-RSA "ambition" to
support multiple versions of 'date' (*nix), which proved to be more
demanding than initially expected. The "new" code speaks for itself.

Currently supported versions of 'date', as of this pull request:
* Linux (Standard Ubuntu)
* FreeBSD
* MacOS and MacOS Ports
* busybox

New functions:

* cert_date_to_timestamp_s()
  Takes* an X509 certificate date, as output by SSL option '-startdate'
  or '-enddate' and creates a 'timestamp' in seconds since epoch.

* offset_days_to_cert_date() [Note: 'days' not 'date']
  Adds* the $offset number of days to the current date and creates an
  X509 "style" certificate date string.

* ff_date_to_cert_date()
  Takes* a fixed-format date and converts it into an X509 certificate
  "style" date string.

* ssl_cert_not_before_date()
  Dedicated function to return an X509 certificate '-startdate' by SSL.

* ssl_cert_not_after_date()
  Dedicated function to return an X509 certificate '-enddate' by SSL.

These functions serve to provide an extensible frame-work for Easy-RSA
to manage all 'date' requirements.

Extras:

Built in reports 'show-expire','show-revoke' and 'show-renew' all use
these functions to interrogate index.txt and the PKI, extensively.

Add error detection to Easy-RSA options which involve "number of days"
and fail for any input which is not a base-10 number. eg. --days=nn

Closes: #593

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-06-08 00:59:54 +01:00
Richard T Bonhomme
78f17179d6
Remove restrictive 30-day window hindering 'renew'
Ref: https://github.com/OpenVPN/easy-rsa/issues/593

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-06-06 14:55:43 +01:00
Richard T Bonhomme
ab392617d4
Correct supplemental help text output
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-06-06 14:35:04 +01:00
Richard T Bonhomme
64828d2134
Merge branch 'TinCanTech-esc-org'
Additional: Insert forced quotes into SSL config file for ALL fields.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-06-03 17:00:55 +01:00
Richard T Bonhomme
a022a5cb2a
ChangeLog: Support ampersand and dollar-sign in vars file (#590)
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-06-03 16:38:58 +01:00
Richard T Bonhomme
68fe46e451
Auto-escape '&' and '$' in 'org' mode fields - Other minor tweaks
Auto-escape '&' ampersand explanation:
'easyrsa' uses 'sed' to build a safe SSL config file, which means
that an unescaped '&' ampersand cannot be used in the 'vars' file.
This is due to 'sed' treating '&' as a special character.

Rather than expect users to know all this and use extended escaping,
to get around 'easyrsa' set_var(), use auto-escape. This allows use
of unescaped '&' in vars file. Like any other character.

Auto-escape '$' dollar-sign explanation:
Using '$' in the 'vars' file MUST be escaped. Escaping '$' to stop
expansion is common knowledge and the first thing a user will try.
Using an escaped '$' in the 'vars' file results in an unescaped '$'
being written to the SSL config file, which is then expanded by
OpenSSL or choked on by LibreSSL. Auto-escaping '$' fixes this.

Add SSL library name to die().

Allow verify_ssl_lib() to run ONLY once.

Improve comments.

Re-order the areas searched for data files to prioritise preferred
locations over old defaults.

Tested-with: OpenSSL and LibreSSL and on Windows and FreeBSD.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-06-03 13:19:28 +01:00
Richard T Bonhomme
678ab06a09
SSL version: Ignore error out, in case of missing SSL config file
Also, re-order 'sed' command; Move CN above DN=org fields. eg: Province etc.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-06-02 02:01:31 +01:00
Richard T Bonhomme
c363e904c1
Ignore unit-test sand-box
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-05-30 18:58:03 +01:00
Richard T Bonhomme
d5f349888a
Auto escape: Unquote 'bad_char' in string disection (Win: mksh)
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-05-28 00:26:03 +01:00
Richard T Bonhomme
83fa2ac23d
Enable verbose unit test log for Linux
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-05-27 23:11:55 +01:00
Richard T Bonhomme
97f301ca39
Merge branch 'TinCanTech-esc-amp-quote-sed'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-05-27 22:52:10 +01:00
Richard T Bonhomme
656a2a240c
Update 'unsupported character list'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-05-27 22:36:54 +01:00
Richard T Bonhomme
8930b9cfab
Correctly quote 'sed' and auto-escape ampersand
Closes: #364
Closes: #582

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-05-27 22:11:35 +01:00
Richard T Bonhomme
0ca54ddd47
Add commnd 'make-safe-ssl' to make a safe SSL config on demand
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-05-27 20:50:43 +01:00
Richard T Bonhomme
cfbfeaae53
Add EasyRSA version to error output
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-05-25 10:24:41 +01:00
Richard T Bonhomme
00675e79da
Add standard user confirmation to 'rewind-renew'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-05-23 16:18:45 +01:00
Richard T Bonhomme
18c530a074
Enable dedicated 'help' test (Linux Only)
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-05-22 17:16:49 +01:00
Richard T Bonhomme
9fd6fe4cf0
Merge branch 'TinCanTech-verbose-revoke-renew'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-05-22 15:03:22 +01:00
Richard T Bonhomme
f52b866ebd
Improve revocation and renewal functions
Changes:
* Improve help
* Move renew_restore_move() out of die() and back to renewal block.
* Minor corrections to user output.
* Add detailed description of which files will be moved/removed.
* Simplify check/create revoked/renewed directory structures.
* Only die on failure to move certificate, otherwise warn only.
  Some files may not be present. eg. PKCS files, already removed.

Manually tested.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-05-22 13:58:38 +01:00