1008 Commits

Author SHA1 Message Date
Richard T Bonhomme
12eecc5d6a
Replace arithmetic number overflow with sensible error detection code
Windows sh.exe cannot multiply two date stamps due to 32bit integer overflow.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-05-05 14:58:27 +01:00
Eric F Crist
6e64026d3a
update OpenSSL to 3.0.3
Compiled OpenSSL 3.0.3 from github for both 64 and 32 bit Windows.  Ran
the wop-test.sh script and passed tests:

* Easy-RSA Unit Tests:
* Windows, no OpenSSL-v3
* System SSL enabled
easyrsa-unit-tests.sh version: 2.3.0
* setup unit-test - ok
* shellcheck abandoned
* >>> BEGIN unit tests:
* >>>>>>: sh C:/Users/ecrist/Desktop/3.1.0-64/easy-rsa/easyrsa-unit-tests.sh -v
easyrsa-unit-tests.sh version: 2.3.0
easyrsa-unit-tests.sh source:  localhost
easyrsa source:                C:/Users/ecrist/Desktop/3.1.0-64/easy-rsa/easyrsa3/easyrsa

* EASYRSA_OPENSSL:
  openssl (env)
  OpenSSL 3.0.3 3 May 2022 (Library: OpenSSL 3.0.3 3 May 2022)
EasyRSA Version Information
Version:     ~VER~
Generated:   ~DATE~
SSL Lib:     OpenSSL 3.0.3 3 May 2022 (Library: OpenSSL 3.0.3 3 May 2022)
Git Commit:  ~GITHEAD~
Source Repo: https://github.com/OpenVPN/easy-rsa

Setup .. ok
>>>>> >>>>> Begin easyrsa rsa tests

... Lots of tests here.

<<<<< <<<<< End easyrsa ed tests
easyrsa-unit-tests.sh version: 2.3.0
easyrsa-unit-tests.sh source:  localhost
easyrsa source:                C:/Users/ecrist/Desktop/3.1.0-64/easy-rsa/easyrsa3/easyrsa

* EASYRSA_OPENSSL:
  openssl (env)
  OpenSSL 3.0.3 3 May 2022 (Library: OpenSSL 3.0.3 3 May 2022)

Unit-test: cleanup
Remove temp dir: C:/Users/ecrist/Desktop/3.1.0-64/easy-rsa/easyrsa3/unit tests
Completed Thu May  5 08:28:30 Central Daylight Time 2022 (Total errors: 0)
* OK
* <<< END unit tests:

Signed-off-by: Eric F Crist <ecrist@secure-computing.net>
2022-05-05 08:35:18 -05:00
Eric F Crist
3991ffdb96
call python3 instead of python in build-dist
Not all the places I want to build the distribution symlink python to
the python3 binary (namely macOS) so just call python3 directly.

Signed-off-by: Eric F Crist <ecrist@secure-computing.net>
2022-05-05 08:35:17 -05:00
Richard T Bonhomme
a3dec9576d
Minor improvement to cleanup() - Always detect terminal first
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-05-05 13:39:13 +01:00
Richard T Bonhomme
36543be760
Improve error detection in cert_dates()
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-05-05 13:37:28 +01:00
Richard T Bonhomme
0948e81304
Detect and filter erroneous duplicate "found 'vars' files"
When 'vars' is in the same directory as 'easyrsa' and they are both
in the current working directory, easyrsa would falsely warn about
"conflicting" 'vars' files.

Filter out this false error by checking if '$prog_dir' is './'

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-05-05 12:37:35 +01:00
Richard T Bonhomme
87e514e3b6
Correct indentation
Follow-up to: 9f0d4bf16d044d5e0d3a8e6b17c5eaa9b1bcbc39

Separate commit for clarity.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-05-05 12:33:44 +01:00
Richard T Bonhomme
9f0d4bf16d
Respect '--vars=file'
Changes to how 'vars' is located and sourced omitted the possibility
that the vars file has been declared via '--vars'.

Move the 'fi' to the correct location so that '--vars' is respected.

Closes: #552 (Over-ruled, due to another, unrelated change)

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-05-05 12:29:07 +01:00
Eric F Crist
ecc7cb72d1
Preparing for v3.0.9 release
This has been an on/off release tag, but we're going to push it out
because there are some that will remain on the v3.0.x branch for a
long time, and OpenSSL 3.x isn't available in all distros/embedded
systems yet (or for a while).

 - Updated OpenSSL for Windows to 1.1.1o
 - Updated ChangeLog for v3.0.9, pulling in most comments for v3.1.0
 - Updated header in easyrsa to point to Github contributors page

Signed-off-by: Eric F Crist <ecrist@secure-computing.net>
2022-05-04 21:29:47 -05:00
Richard T Bonhomme
814fab9bd3
Make cert_dates() '--fix-offset' Windows compatible
date.exe does not support output format '+%s' as input.

Instead, use date.exe "string" not seconds since epoch.

Also, force easyrsa_openssl() 'makesafeconf' to move the the temp-file
to the target file.  Otherwise, Windows users are expected to confirm
over-write, every time.

Also, minor variable name changes, for clarity.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-05-04 00:09:18 +01:00
Richard T Bonhomme
3b8f9137b0
Do not declare EASYRSA_FIX_OFFSET, must be set by user only
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-05-03 20:53:45 +01:00
Richard T Bonhomme
7a5212c9a9
Introduce '--fix-offset' for fixed start/end date certificates
The initial idea was to mask the actual certificate creation date.
The reason was to further anonymise user certificates. (YMMV)

There is now a second part to this date "fixing":
* This allows for all certificates to expire on the same day.

Using command option '--fix-offset=nnn', all certificates will be created
* with a 'notBefore' date of January 1st of the current year.
* with a 'notAfter' date of the day-of-year number from '--fix-offset',
  in the final year, as per EASYRSA_CERT_EXPIRE (Default 825 days).
  The default 825 days results in 2 years plus the offset given.

This can also be set in the 'vars' file, for convenience.

The default day-of-year offered is 183; either July 2 or 3 (leap year).

Follow-up to: #550 (Replaces 'nodatetime' with '--fix-offset')

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-05-03 20:25:00 +01:00
Richard T Bonhomme
8c5ee3df1b
Merge branch 'ValdikSS-startdate-year-v3'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-05-03 20:16:50 +01:00
Richard T Bonhomme
1620cfe0d1 Merge branch 'startdate-year-v3' of ssh://github.com/ValdikSS/easy-rsa-ipsec into ValdikSS-startdate-year-v3 2022-05-03 20:15:29 +01:00
Richard T Bonhomme
7ee6526b77
Merge branch 'AndersBlomdell-master'
With general code style improvements.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-05-03 19:39:54 +01:00
Anders Blomdell
13cc6034e4 Display certificates in UTF8 2022-05-02 17:13:31 +02:00
Richard T Bonhomme
8d1be1c9cf
Only set a temp-dir session name _if_ temp-dir session was created
Also, minor log improvement to op-test.sh

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-05-01 22:21:20 +01:00
ValdikSS
8458f65016 nodatetime: use CA day of creation for notAfter of issuing certificate 2022-04-30 02:08:11 +03:00
ValdikSS
f77951d058 Set notBefore/notAfter to the beginning of the year
This modification adds "nodatetime" argument to build-client-full
and build-server-full which issues the certificate with notBefore
and notAfter date set to 1 Jan, with difference in the year only.

It could be useful for a VPN service to prevent client and server
certificate generation date and time disclosure.
2022-04-30 00:37:19 +03:00
Richard T Bonhomme
26dd7af541
Add label '%COPY_EXTS%' for --copy-ext feature
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-29 14:20:53 +01:00
Richard T Bonhomme
b17499d2ef
Option '--copy-ext' insert "copy_extensions = copy" into config
For '--copy-ext' the "copy_extensions = copy" must be inserted into
the SSL config file, section [defaul_ca]. As with all other insertions,
use the same 'awk' script with a new label '%COPY_EXTS%'.

Closes: #548

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-29 13:57:10 +01:00
Richard T Bonhomme
c4802de368
Improve --subject-alt-name
Add '--san' option alias name and reformat help to include '--san'.

Refactor code for readability.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-29 12:19:21 +01:00
Richard T Bonhomme
13b2fc36cb
Use a fake function to declare variables for shellcheck 2154
EasyRSA set_var() is not known by shellcheck, so "fake declare"
variables that otherwise incorrectly trigger SC2154.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-29 00:41:27 +01:00
Richard T Bonhomme
63dd27a98b
Improve/simplify Fatal error: Missing *expected* "$val" to "$opt"
Fatal errors should be precisely coded, not "obfuscated".

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-28 22:47:03 +01:00
Richard T Bonhomme
a3db60f229
Always make a safe SSL config file for LibreSSL
LibreSSL chokes on 'rand' without a config file and dies on the
standard config file.

A common fix would be to redirect error out to '/dev/null' but this
would obviously mask all error messages, which is not satisfactory.

Instead, always make a safe config file before the temporary session
directory and any temp-files are required.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-28 21:02:16 +01:00
Richard T Bonhomme
5e57887c39
Harden sourcing vars and warn for potential problems
In 'org' mode, fields such as EASYRSA_REQ_ORG can be abused.

If the field contains single quote ('), ampersand (&), back-tick (`),
dollar sign ($) or hash (#) then the result is undefined.

Due to EasyRSA running on Linux and Windows and supporting multiple
SSL Libraries, it is not feasible to support these characters.

Add a check to determine if any unsupported characters are found in
the vars file and issue a warning if they are found.

Add a sub-shell test to source vars.  If the test fails then exit
gracefully, with a specific error message.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-28 18:52:21 +01:00
Richard T Bonhomme
ecbc6103bc
Move "detect host" to a separate function
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-28 18:45:58 +01:00
Richard T Bonhomme
05b969df82
Improve 'revoke-renewed' success message
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-28 18:42:01 +01:00
Richard T Bonhomme
c52073422d
Rename $want_init_pki to $no_pki_required (NFC)
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-28 16:05:06 +01:00
Richard T Bonhomme
071405b1d5
Use $EASYRSA_DIGEST instead of hard-coded 'digest=-sha256'
Also, remove a duplicate EASYRSA_DIGEST in easyrsa_openssl().

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-28 15:03:49 +01:00
Richard T Bonhomme
fac4abf074
Make inline file failure only a warning
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-28 14:25:20 +01:00
Richard T Bonhomme
0248064235
Purge $req_opts from build_full()
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-28 14:19:47 +01:00
Richard T Bonhomme
410a3d3286
Purge $opts from sign_req()
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-28 13:59:07 +01:00
Richard T Bonhomme
2194c215f3
Purge $opts from gen_req()
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-28 13:48:55 +01:00
Richard T Bonhomme
34ad764d99
Use file-name $EASYRSA_ALGO_PARAMS to output test elliptic curve
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-28 12:54:44 +01:00
Richard T Bonhomme
71076aa608
Corrections to help text (NFC)
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-28 12:52:38 +01:00
Richard T Bonhomme
61182c5fe1
Update help for 'revoke-renewed'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-28 00:33:57 +01:00
Richard T Bonhomme
0e2cf100a8
Simplify 'case' for revocation reasons list
Effects: revoke and revoke-renewed

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-28 00:13:46 +01:00
Richard T Bonhomme
8df0346f39
Minor improvements to revoke/renew/revoke-renewed
Tested manually.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-27 23:35:50 +01:00
Richard T Bonhomme
ac12dad028
General improvements to revoke/renew/revoke-renewed
Ensure that declaration of file-names which are from serial-numbers
are declared after the serial-number has been extracted.

Move confirmation prompts to the last point before action.

Correct and improve #comments, "prompts" and "error messages".

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-27 22:31:19 +01:00
Richard T Bonhomme
345341013c
ChangeLog: Add 'revoke-renewed'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-27 21:21:27 +01:00
Richard T Bonhomme
590c9787e7
Merge branch 'TinCanTech-revoke-renewed'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-27 20:10:03 +01:00
Richard T Bonhomme
ef22701878
Introduce 'revoke-renewed'
When easyrsa "renews" a certificate, the current certificate is moved
to a sub-directory for renewed certificates and renamed to the serial
number of the certificate.

This makes it difficult to subsequently revoke the old certificate.

The new behaviour is for easyrsa to move the certificate without
renaming the file.  This means the certificate can be revoked by name.

Once a renewed certificate is revoked, it is moved to the 'revoked'
sub-directory, along with all other revoked certificates.

The same mechanism also manages keys, requests, PKCS and inline files.

Behaviour summary:

* revoke moves certificates to 'revoked' - Unchanged
  Rename the certificate to its serial number - Unchanged

* renew moves certificates to 'renewed' - Unchanged
  renew does not rename the certificate to its serial number - Changed

  Important:
  Only one certificate of a specific name (eg. john) can be renewed
  at the same time.
  To renew another certificate called 'john' the first MUST be revoked.

* revoke-renewed:
  takes the certificate from 'renewed' - Changed
  moves the certifiate to 'revoked' - Changed
  renames the certificate to its serial number - Unchanged

* All revoked certificates are moved to the 'revoked' sub-directory.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-27 19:27:34 +01:00
Richard T Bonhomme
0238b5cdba
When $want_init_pki is set then also skip session setup
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-27 14:39:24 +01:00
Richard T Bonhomme
f5a3950699
Merge branch 'TinCanTech-revoke-v2'
Plus a minor correction to order of checks.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-27 11:40:59 +01:00
Richard T Bonhomme
7914255760
Add "reason" check
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-27 03:28:23 +01:00
Richard T Bonhomme
fdcaf6cf79
revoke(): Purge unquoted $opts + General improvements
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-27 02:40:11 +01:00
Richard T Bonhomme
3cff9494af
Consolidate 'nopass' for PKCS export functions
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-26 17:51:00 +01:00
Richard T Bonhomme
c1765bb54f
Add 'nopass' option to 'export-p12' command
Plus a minor correction to white-space.

Closes: #411

Original commit:

commit e93af47b0112b13e221a1bf28d36afaf5f5719df
Author: itaru2622 <itaru2622@gmaiil.com>
Date:   Wed Oct 7 20:47:26 2020 +0900

    supporting nopass option for export-p12

    usage:
      easyrsa export-p12 EntityName nopass

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-26 15:51:50 +01:00
Richard T Bonhomme
d9ec677ac7
Introduce 'show-crl'
Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
2022-04-26 00:44:37 +01:00