Upgrade EasyRSA v2.x to v3.x PKI stops working from v3.0.9-rc1 onward
The command easyrsa upgrade pki stops working in accordance with this guide starting on v3.0.9-rc1.
With Version 3.0.7 and 3.0.8 the upgrade works as expected and the v2.x vars are upgraded to the v3 equivalent.
Starting from 3.0.9-rc1 the following error occurs:
$ ./easyrsa upgrade pki
Found: /home/dev/src/pki_test/EasyRSA-v3.0.9-rc1/vars
Found: ./vars
Easy-RSA error:
Conflicting 'vars' files found.
Priority should be given to your PKI vars file:
* /home/dev/src/pki_test/EasyRSA-v3.0.9-rc1/pki/vars
Host: nix | Linux | /bin/bash
After which the upgrade process is aborted. I believe this is related to issue 589
The problem here is that easyrsa has found two different vars files and does not know which one to use for the upgrade.
@amerello can you confirm which of the two vars files is the correct one in this case ?
FTR, easyrsa would prefer to use the vars file found in the PKI, however, as you are upgrading from EasyRSA 2.x, this may be a situation which I have over-looked.
@TinCanTech both vars referenced are the same file, one is the relative path (./vars) and the other the absolute path (/home/dev/src/pki_test/EasyRSA-v3.0.9-rc1/vars) in this case.
The guide requests in step 2 to copy the old files:
Copy your existing EasyRSA version 2 files and directories into ./easyrsa3
This includes the old vars (v2.x) with export, which at least on version 3.0.7 and 3.0.8 are replaced with the new format set_var during the upgrade.
That upgrade doesn't work anymore starting from version 3.0.9-rc1
both
varsreferenced are the same file, one is the relative path (./vars) and the other the absolute path (/home/dev/src/pki_test/EasyRSA-v3.0.9-rc1/vars) in this case.
Thanks.
In this case, I believe I have resolved that particular circumstance in a later patch, I will search and update here when I have confirmed.
For the time being I cannot offer a resolution to this particular problem.
I will confirm that, with the current release, this is a bug.
Thanks.
@TinCanTech thank you for looking into this!
The code to detect the duplicate ./vars verses the /full/path/vars file was introduced here: https://github.com/OpenVPN/easy-rsa/commit/26b7247f708f2b895c289aefaab9b99023aa7860#diff-facbd438107d2ef365738070a1bd97ab30395e1e821eec939bd766b8a73b9464R2975
@amerello Can you test the same upgrade with git/master version, please ?
Please make a backup of your data first.
@TinCanTech running the upgrade from git/master (e5ec1ab) I don't experience the vars error that aborts the process at the beginning.
After the existing certificate verification I see the following output though:
Found current CA at: /home/dev/src/pki_test/easy-rsa/easyrsa3/keys/ca.crt
Type the word 'yes' to continue, or any other input to abort.
* Confirm CA shown above is correct: yes
Easy-RSA error:
Non-existant temporary session:
Easy-RSA error:
easyrsa_openssl - Failed to create temporary file (1)
EasyRSA Version Information
Version: ~VER~
Generated: ~DATE~
SSL Lib: OpenSSL 3.0.2 15 Mar 2022 (Library: OpenSSL 3.0.2 15 Mar 2022)
Git Commit: ~GITHEAD~
Source Repo: https://github.com/OpenVPN/easy-rsa
Version: dev | nix | Linux | /bin/bash | ssl_lib not set
So the upgrade isn't successful, like up to 3.0.8, but this seems to be a different issue than the vars one. Do you have an idea what could be the problem here? It might be related to changes introduced in c300f60 or here 68fe46e, which wasn't there yet on 3.0.8, but I'm a bit out of my zone here, so I'm probably wrong.
Thanks again for taking the time to look into this
@amerello I cannot replicate your problem.
For starters, the output above is incomplete, there should be warnings prior to verifying your CA.
This is what I expect to see:
tct@home:~/git/easy-rsa/easy-rsa-v2-test$ ./easyrsa upgrade pki
NOTE: If you run ./clean-all, I will be doing a rm -rf on /home/tct/git/easy-rsa/easy-rsa-v2-test/keys
NOTE: If you run ./clean-all, I will be doing a rm -rf on /home/tct/git/easy-rsa/easy-rsa-v2-test/keys
* Using Easy-RSA configuration from: /home/tct/git/easy-rsa/easy-rsa-v2-test/vars
WARNING
=======
Move your vars file to your PKI folder, where it is safe!
WARNING
=======
=========================================================================
* WARNING *
Found settings from EasyRSA-v2 which are not compatible with EasyRSA-v3.
Before you can continue, EasyRSA must upgrade your settings and PKI.
* Found EASYRSA and vars file:
/home/tct/git/easy-rsa/easy-rsa-v2-test
/home/tct/git/easy-rsa/easy-rsa-v2-test/vars :
Further info:
* https://community.openvpn.net/openvpn/wiki/easyrsa-upgrade
Easyrsa upgrade version: v1.0a (2020/01/08)
=========================================================================
This upgrade will TEST that the upgrade works BEFORE making any changes.
Type the word 'yes' to continue, or any other input to abort.
* EasyRSA **TEST** upgrade (Changes will NOT be written): yes
-------------------------------------------------------------------------
Certificate:
Data:
Version: 3 (0x2)
Serial Number:
7a:38:ac:cd:e4:cb:aa:30:e2:2e:4a:c4:08:fb:6f:f8:9f:64:b2:be
Signature Algorithm: sha256WithRSAEncryption
Issuer:
countryName = US
stateOrProvinceName = CA
localityName = SanFrancisco
organizationName = Fort-Funston
organizationalUnitName = changeme
commonName = changeme
name = changeme
emailAddress = [email protected]
Validity
Not Before: Jul 29 18:02:05 2022 GMT
Not After : Jul 26 18:02:05 2032 GMT
Subject:
countryName = US
stateOrProvinceName = CA
localityName = SanFrancisco
organizationName = Fort-Funston
organizationalUnitName = changeme
commonName = changeme
name = changeme
emailAddress = [email protected]
X509v3 extensions:
X509v3 Subject Key Identifier:
32:98:62:4D:E7:84:62:3D:F3:F8:D7:4D:7D:7F:C4:6C:02:BC:27:87
X509v3 Authority Key Identifier:
keyid:32:98:62:4D:E7:84:62:3D:F3:F8:D7:4D:7D:7F:C4:6C:02:BC:27:87
DirName:/C=US/ST=CA/L=SanFrancisco/O=Fort-Funston/OU=changeme/CN=changeme/name=changeme/[email protected]
serial:7A:38:AC:CD:E4:CB:AA:30:E2:2E:4A:C4:08:FB:6F:F8:9F:64:B2:BE
X509v3 Basic Constraints:
CA:TRUE
-------------------------------------------------------------------------
Found current CA at: /home/tct/git/easy-rsa/easy-rsa-v2-test/keys/ca.crt
Type the word 'yes' to continue, or any other input to abort.
* Confirm CA shown above is correct: yes
cp: cannot stat '/home/tct/git/easy-rsa/easy-rsa-v2-test/keys/index.txt.attr': No such file or directory
Notice
------
============================================================================
The update has failed but NOTHING has been lost.
ERROR: Failed to copy /home/tct/git/easy-rsa/easy-rsa-v2-test/keys/index.txt.attr to /home/tct/git/easy-rsa/easy-rsa-v2-test/pki
----------------------------------------------------------------------------
Further info:
* https://community.openvpn.net/openvpn/wiki/easyrsa-upgrade#ersa-up23-fails
Easyrsa3 upgrade FAILED
============================================================================
@TinCanTech i should have mentioned that i removed all the output from my previous message until after the certificate information is printed out, because it contains sensitive details that I thought shouldn't be relevant to this issue. I can edit the output to include everything but replacing the PII, next time I'm at my workstation.
~~Can you post the complete output with redacted certificate data please.~~
@amerello I have solved this, so you do not need to post any further output.
@amerello can you please confirm if this works for you.
@TinCanTech I just was able to get back to this. Running from git/master bee93cf8692c3ff52c6256960d59ce5f07d8bc3c
I can confirm that upgrade works. Thanks for fixing this!
Thank you very much for thoroughly testing and feeding back your experience.
Mainly notes for someone else trying to upgrade:
I found that the easiest way to get a 2 to 3 upgrade done is to use 3.0.7 (and maybe 3.0.8, I did not test that, but 3.0.9 was failing with the error from this issue) - latest 3.1 fails the vars file since it does 3.x checks on the 2.x vars file (it complains that "export" is not allowed or if those are removed it gets the "conflicting vars file" or if --vars=./vars is given vars file not found)
(I don't know if some intermediate 3.1 versions worked as well, this issues appears to imply that they did)
After that migration, upgrading to latest 3.1 works.
If the upgrade fails with CA certificate does not match vars/vars.bat file settings, run sh -x easyrsa upgrade pki to see which checks fail... (No idea how the Windows version works)
The OpenVPN wiki page was used as a base for the upgrade.
(I see that master removed all of the upgrade functionality. Creating a separate script for the upgrade might be the easiest way to keep other easy-rsa changes from affecting the upgrade. Ideally with an automated test of the migration with each PR / release...)