pivpn: Official OpenVPN Connect Android client error with PiVPN on Stretch: Requested encryption or digest alg not available
Apologies for posting this as an issue here, but the IRC is slow, and we really need a forum or something where the information is more persistent than on IRC anyway.
I have upgraded my Pi OS from Jesse to Stretch a few days ago and finally got around to install PiVPN on the Pi, using the recommended installation method:
curl -L https://install.pivpn.io | bash
Everything went smooth, with the exception of a warning screen that the installed OS is not explicitly supported (which was no surprise).
After installation, I have created a new .ovpn
profile for my Android device, and imported in the the official OpenVPN client: OpenVPN Connect
.
However, when attempting to connect (after entering the password), this error popped out:
CORE_ERROR PolarSSL: error parsing config private key : PKCS5 - Requested encryption or digest alg not available
I did some digging, and the cause is that the encrypted private key in the .ovpn
file uses a newer format that is not supported by the current Android OpenVPN client.
There are several options:
- Don’t use a password when creating the
.ovpn
file (NOT recommended!) - Downgrade to Jesse.
- Wait for an upgrade of the Android OpenVPN client. Should happen sooner than later, but it may take a while.
- Use an alternative client that supports the newer format. Apparently OpenVPN for Android by Arne Schwabe does so. BEWARE: Untested, use at your ow risk.
- Re-encode the private key in the
.ovpn
file to an older format that is understood by OpenVPN Connect
For the more impatient people, like me, here is how to re-encode the private key:
cd ~/ovpns
cp not-working-profile.ovpn not-working-profile-backup.ovpn
openssl rsa -aes256 -in not-working-profile.ovpn -out new-key-file.key
This will ask for the key password and will generate a new key file (asking for a new password - you can use the same one), containing ONLY the key, having the following header:
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-256-CBC,XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
<private key content follows>
To compare, the old private key header (from the .ovpn
file) looks like this:
-----BEGIN ENCRYPTED PRIVATE KEY-----
<private key content follows>
Now, after obtaining the new key, use your favorite text editor and open the .ovpn
file and replace everything in between the <key>
and </key>
tags with the newly generated key.
Save the file, and then re-import the profile on your device. Enjoy!
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 17
- Comments: 66 (7 by maintainers)
@TimmThaler your scripted worked perfectly! Once I adjusted my fat fingers for three password entries.
I did a wget of your raw .sh file from github and run it with sudo bash (otherwise unable to access the openvpn pki folder)
-my build = Linux version 4.9.59-v7+ on armv71 Rasp PI 3
Thanks.
@cfcolaco:
.ovpn
file uses.ovpn
file could be encrypted as well.I am strongly against PiVPN promoting any other client than the official one for the reasons listed above.
Like I said, I feel that until the official mobile client will be updated, if the user indicates that the mobile client version is
1.1.17
or below, PiVPN should generate an AES-256 encrypted private key, that is compatible with the current official mobile client.FYI, as I mentioned on other threads, the root cause has been identified in mbedTLS not supporting the hmac algo used by openssl 1.1 when encrypting the private key. This resulted in mbedTLS being unable to decrypt the key.
A permament fix to this problem has been proposed to mbedTLS upstream in https://github.com/ARMmbed/mbedtls/pull/1219
If such change will be ACK’d and then merged, it will make its way into mbedTLS and then OpenVPN Connect. At that point there shouldn’t be any incompatibility anymore.
Thanks, dude. it worked for me thumb-up.
Based on killermosi’s instructions I created a script that does convert the original ovpn file of a client from an rsa to aes256 key so that it will be usable with the app “OpenVPN Connect”.
I would appreciate some testing 😃
The Android client was updated to version
1.1.22
(several versions actually) since my previous comment, and this may render this entire issue moot. Which is a good thing 👍Beware: there are fresh reviews complaining about functionality (and bad UI/UX), so if you’re using the client for mission critical tasks, you may want to deffer upgrading to the latest version, at least for several days.
I’ll come back with a comment once I’ll upgrade the client.
Thank you. Your solution for making a new key that works in OpenVPN Connect works perfectly.