Skip to contentSkip to conversation

Fix loading PKCS12 files on Windows

PATCH In review Lev Stipakov 2 participants 5 messages Oct 6, 2021 – Oct 7, 2021 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix loading PKCS12 files on Windows

From: Lev Stipakov <[email protected]...>

Starting from 2.5.4 we have switched to MSVC builds, including dependencies such as OpenSSL.

When we link with natively-built OpenSSL .DLLs (not cross compiled with MinGW), we are expected to include applink.c, which provides glue between OpenSSL BIO layer and compiler run-time. This doesn't apply to ARM64.

Failure to do that results in "no OPENSSL_Applink" fatal error when calling, for example, d2i_PKCS12_fp(), which we do when loading PKCS12 files.

---
 src/openvpn/ssl_openssl.c | 4 ++++
 1 file changed, 4 insertions(+)
src/openvpn/ssl_openssl.c +4 -0
index 31d94f2b..27fb66aa 100644
@@ -65,6 +65,10 @@
 #include <openssl/ec.h>
 #endif
 
+#if defined(_MSC_VER) && !defined(_M_ARM64)
+#include <openssl/applink.c>
+#endif
+
 /*
  * Allocate space in SSL objects in which to store a struct tls_session
  * pointer back to parent.
Signature · 1 line
2.23.0.windows.1
Acked-by on v1 1/1
#1 lore raw

As discussed on IRC, and checked with the OpenSSL documentation and "Internet knowledge". Most important: confirmed that it breaks with --pkcs12 without that patch, and works with it (IRC, I did not test myself).

Your patch has been applied to the master and release/2.5 branch.

commit af5de933a0633436e0fe00c42464f4a7ab5ac509 (master) commit f397c3bfe728e0163fe6d226f62874e1dd25ec60 (release/2.5)

Author: Lev Stipakov
Date:   Wed Oct 6 12:07:09 2021 +0300
     Fix loading PKCS12 files on Windows

     Signed-off-by: Lev Stipakov <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg22920.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#3 lore raw
In reply to a message not in the archive

Adding openvpn-devel.

Quoted 1 line

Does that mean that CFG and Spectre protection are already included?

Those are merged into the "master" branch, but not into "released". We could probably include those into the next 2.5 release? Otherwise they'll be part of 2.6.

-Lev

#4 lore raw

Hi,

Quoted 5 lines · Lev Stipakov
Quoted 1 line

Does that mean that CFG and Spectre protection are already included?

Those are merged into the "master" branch, but not into "released". We could probably include those into the next 2.5 release? Otherwise they'll be part of 2.6.

"You tell me".

It was not relevant before as we did not build 2.5 with MSVC (except for ARM).

gert

Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you 
 feed honest figures into a computer, honest figures come out. Never doubted 
 it myself till I met a computer with a sense of humor."
                             Robert A. Heinlein, The Moon is a Harsh Mistress

Gert Doering - Munich, Germany                             [email protected]...
#5 lore raw

Hi,

Quoted 5 lines
Quoted 3 lines

Those are merged into the "master" branch, but not into "released". We could probably include those into the next 2.5 release? Otherwise they'll be part of 2.6.

"You tell me".

The probable performance impact should be a less issue for master, which in most cases will use dco on Windows.

For 2.5, let's conduct performance tests first. Balancing security with performance tradeoffs is a difficult task.

Signature · 1 line
-Lev