msvc: switch to openssl3
PATCH 1/1 msvc: switch to openssl3
From: Lev Stipakov <[email protected]...>
- add openssl3 port from https://github.com/microsoft/vcpkg/pull/20428/files
with small changes:
portfile.cmake 2022-01-24 11:02:46.066088800 +0200 renamed from portfile.cmake.orig 2022-01-24 11:04:44.914467900 +0200 +0 -2
@@ -5,8 +5,8 @@ vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO openssl/openssl - REF openssl-3.0.0 - SHA512
50b4fefa3e5a3359e7b06bfbc4ecc525ef9d76e13d087aa8e2d29880f08f74cc9d0c76b9bf1895c118def2bb0e4db0095e799a752b64b60721a423bd2cf989da
+ REF openssl-3.0.1
+ SHA512
7f303769a3a796b88478399d42aa2a9a70dc74f62c975bbb93e8903e3bb8e25f16ecfc436186c2d4aa7383302c73ad1dd8ac4fccaa589062bbce6059d6073f18
)
if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
@@ -114,13 +114,13 @@
if(VCPKG_TARGET_IS_UWP OR VCPKG_TARGET_IS_WINDOWS)
message(STATUS "Building ${TARGET_TRIPLET}-dbg")
vcpkg_execute_required_process(- COMMAND ${JOM} /K /J ${VCPKG_CONCURRENCY} /F makefileinstall_dev
+ COMMAND ${JOM} /K /J ${VCPKG_CONCURRENCY} /F makefileinstall_dev install_runtime
WORKING_DIRECTORY
"${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg"
LOGNAME install-${TARGET_TRIPLET}-dbg
)
message(STATUS "Building ${TARGET_TRIPLET}-rel")
vcpkg_execute_required_process(- COMMAND ${JOM} /K /J ${VCPKG_CONCURRENCY} /F makefileinstall_dev
+ COMMAND ${JOM} /K /J ${VCPKG_CONCURRENCY} /F makefileinstall_dev install_runtime
WORKING_DIRECTORY
"${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel"
LOGNAME install-${TARGET_TRIPLET}-rel
)
@@ -129,13 +129,13 @@
else()
message(STATUS "Building ${TARGET_TRIPLET}-dbg")
vcpkg_execute_required_process(- COMMAND ${MAKE} -j ${VCPKG_CONCURRENCY} install_dev
+ COMMAND ${MAKE} -j ${VCPKG_CONCURRENCY} install_devinstall_runtime
WORKING_DIRECTORY
"${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg"
LOGNAME install-${TARGET_TRIPLET}-dbg
)
message(STATUS "Building ${TARGET_TRIPLET}-rel")
vcpkg_execute_required_process(- COMMAND ${MAKE} -j ${VCPKG_CONCURRENCY} install_dev
+ COMMAND ${MAKE} -j ${VCPKG_CONCURRENCY} install_devinstall_runtime
WORKING_DIRECTORY
"${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel"
LOGNAME install-${TARGET_TRIPLET}-rel
)@@ -161,6 +161,17 @@
endif()
+if(VCPKG_TARGET_IS_WINDOWS)
+ file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/tools/openssl/")
+ file(RENAME "${CURRENT_PACKAGES_DIR}/bin/openssl.exe"
"${CURRENT_PACKAGES_DIR}/tools/openssl/openssl.exe")
+
+ file(REMOVE
+ "${CURRENT_PACKAGES_DIR}/debug/bin/openssl.exe"
+ )
+endif()
+ +vcpkg_copy_tool_dependencies("${CURRENT_PACKAGES_DIR}/tools/openssl") +
if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/lib/libcrypto.a"
"${CURRENT_PACKAGES_DIR}/debug/lib/libssl.a"
@@ -184,4 +195,4 @@
)
file(INSTALL "${CURRENT_PORT_DIR}/usage"
DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}"-)
\ No newline at end of file
+)
- use sizeof(void *) since msvc doesn't support sizeof of function ptr
- use XKEY_PROV_PROPS macro instead of props since msvc requires constant expression in aggregate initializers
--- .github/workflows/build.yaml | 2 +- .../openssl3/detect_platform.cmake | 86 ++++++++ contrib/vcpkg-ports/openssl3/portfile.cmake | 198 ++++++++++++++++++ contrib/vcpkg-ports/openssl3/usage | 11 + contrib/vcpkg-ports/openssl3/vcpkg.json | 7 + .../vcpkg-ports/pkcs11-helper/portfile.cmake | 2 +- src/openvpn/xkey_helper.c | 4 +- src/openvpn/xkey_provider.c | 13 +- 8 files changed, 311 insertions(+), 12 deletions(-) create mode 100644 contrib/vcpkg-ports/openssl3/detect_platform.cmake create mode 100644 contrib/vcpkg-ports/openssl3/portfile.cmake create mode 100644 contrib/vcpkg-ports/openssl3/usage create mode 100644 contrib/vcpkg-ports/openssl3/vcpkg.json
.github/workflows/build.yaml +1 -1
@@ -294,7 +294,7 @@ jobs: uses: lukka/[email protected]... with: vcpkgGitCommitId: 'a2fcb03749ff5897b5985092934dc6057680c789' - vcpkgArguments: 'openssl lz4 lzo pkcs11-helper tap-windows6' + vcpkgArguments: 'openssl3 lz4 lzo pkcs11-helper tap-windows6' vcpkgTriplet: '${{ matrix.triplet }}-windows-ovpn' cleanAfterBuild: false
contrib/vcpkg-ports/openssl3/detect_platform.cmake new file +86 -0
86 lines not on this page · raw message
contrib/vcpkg-ports/openssl3/portfile.cmake new file +198 -0
198 lines not on this page · raw message
contrib/vcpkg-ports/openssl3/usage new file +11 -0
@@ -0,0 +1,11 @@ +The package openssl3 can be imported via CMake FindOpenSSL module: + + find_package(OpenSSL REQUIRED) + target_link_libraries(main PRIVATE OpenSSL::SSL OpenSSL::Crypto) + +Also, FindPkgConfig module can be used if pkg-config(.pc) files are installed: + + find_package(PkgConfig REQUIRED) + pkg_check_modules(openssl REQUIRED IMPORTED_TARGET GLOBAL openssl>=3.0) + + target_link_libraries(main PRIVATE PkgConfig::openssl)
contrib/vcpkg-ports/openssl3/vcpkg.json new file +7 -0
@@ -0,0 +1,7 @@ +{ + "name": "openssl3", + "version-semver": "3.0.1", + "description": "TLS/SSL and crypto library", + "homepage": "https://www.openssl.org/", + "license": "Apache-2.0" +}
contrib/vcpkg-ports/pkcs11-helper/portfile.cmake +1 -1
@@ -23,7 +23,7 @@ vcpkg_build_nmake( PROJECT_NAME Makefile.w32-vc OPTIONS OPENSSL=1 - OPENSSL_HOME=${CURRENT_PACKAGES_DIR}/../openssl_${TARGET_TRIPLET} + OPENSSL_HOME=${CURRENT_PACKAGES_DIR}/../openssl3_${TARGET_TRIPLET} ) file(INSTALL ${SOURCE_PATH}/include/pkcs11-helper-1.0 DESTINATION ${CURRENT_PACKAGES_DIR}/include/)
src/openvpn/xkey_helper.c +2 -2
@@ -125,8 +125,8 @@ xkey_load_generic_key(OSSL_LIB_CTX *libctx, void *handle, EVP_PKEY *pubkey, {"xkey-origin", OSSL_PARAM_UTF8_STRING, (char *) origin, 0, 0}, {"pubkey", OSSL_PARAM_OCTET_STRING, &pubkey, sizeof(pubkey), 0}, {"handle", OSSL_PARAM_OCTET_PTR, &handle, sizeof(handle), 0}, - {"sign_op", OSSL_PARAM_OCTET_PTR, (void **) &sign_op, sizeof(sign_op), 0}, - {"free_op", OSSL_PARAM_OCTET_PTR, (void **) &free_op, sizeof(free_op), 0}, + {"sign_op", OSSL_PARAM_OCTET_PTR, (void **) &sign_op, sizeof(void *), 0}, + {"free_op", OSSL_PARAM_OCTET_PTR, (void **) &free_op, sizeof(void *), 0}, {NULL, 0, NULL, 0, 0}};/* Do not use EVP_PKEY_new_from_pkey as that will take keymgmt from pubkey */
src/openvpn/xkey_provider.c +5 -8
@@ -44,9 +44,6 @@#include <openssl/evp.h> #include <openssl/err.h> -/* propq set all on all ops we implement */ -static const char *const props =XKEY_PROV_PROPS ; -/* A descriptive name */ static const char *provname ="OpenVPN External Key Provider" ;
@@ -592,9 +589,9 @@ static const OSSL_DISPATCH ec_keymgmt_functions[] = { };const OSSL_ALGORITHM keymgmts[] = { - {"RSA:rsaEncryption" , props, rsa_keymgmt_functions,"OpenVPN xkey RSA Key Manager" }, - {"RSA-PSS:RSASSA-PSS" , props, rsa_keymgmt_functions,"OpenVPN xkey RSA-PSS Key Manager" }, - {"EC:id-ecPublicKey" , props, ec_keymgmt_functions,"OpenVPN xkey EC Key Manager" }, + {"RSA:rsaEncryption" ,XKEY_PROV_PROPS , rsa_keymgmt_functions,"OpenVPN xkey RSA Key Manager" }, + {"RSA-PSS:RSASSA-PSS" ,XKEY_PROV_PROPS , rsa_keymgmt_functions,"OpenVPN xkey RSA-PSS Key Manager" }, + {"EC:id-ecPublicKey" ,XKEY_PROV_PROPS , ec_keymgmt_functions,"OpenVPN xkey EC Key Manager" }, {NULL ,NULL ,NULL ,NULL } };
@@ -1074,8 +1071,8 @@ static const OSSL_DISPATCH signature_functions[] = { };const OSSL_ALGORITHM signatures[] = { - {"RSA:rsaEncryption" , props, signature_functions,"OpenVPN xkey RSA Signature" }, - {"ECDSA" , props, signature_functions,"OpenVPN xkey ECDSA Signature" }, + {"RSA:rsaEncryption" ,XKEY_PROV_PROPS , signature_functions,"OpenVPN xkey RSA Signature" }, + {"ECDSA" ,XKEY_PROV_PROPS , signature_functions,"OpenVPN xkey ECDSA Signature" }, {NULL ,NULL ,NULL ,NULL } };
Signature · 1 line
2.23.0.windows.1
Hi
Quoted 86 lines · Lev Stipakov
From: Lev Stipakov <[email protected]...>
- add openssl3 port from
https://github.com/microsoft/vcpkg/pull/20428/files
with small changes:portfile.cmake 2022-01-24 11:02:46.066088800 +0200 renamed from portfile.cmake.orig 2022-01-24 11:04:44.914467900 +0200 +0
-2@@ -5,8 +5,8 @@ vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO openssl/openssl - REF openssl-3.0.0 - SHA51250b4fefa3e5a3359e7b06bfbc4ecc525ef9d76e13d087aa8e2d29880f08f74cc9d0c76b9bf1895c118def2bb0e4db0095e799a752b64b60721a423bd2cf989da
portfile.cmake 2022-01-24 11:02:46.066088800 +0200 renamed from portfile.cmake.orig 2022-01-24 11:04:44.914467900 +0200 +2
-0+ REF openssl-3.0.1 + SHA5127f303769a3a796b88478399d42aa2a9a70dc74f62c975bbb93e8903e3bb8e25f16ecfc436186c2d4aa7383302c73ad1dd8ac4fccaa589062bbce6059d6073f18
)
if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")portfile.cmake 2022-01-24 11:02:46.066088800 +0200 renamed from portfile.cmake.orig 2022-01-24 11:04:44.914467900 +0200 +0
-1@@ -114,13 +114,13 @@ if(VCPKG_TARGET_IS_UWP OR VCPKG_TARGET_IS_WINDOWS) message(STATUS "Building ${TARGET_TRIPLET}-dbg") vcpkg_execute_required_process( - COMMAND ${JOM} /K /J ${VCPKG_CONCURRENCY} /F makefile
install_dev
+ COMMAND ${JOM} /K /J ${VCPKG_CONCURRENCY} /F makefileinstall_devinstall_runtime
WORKING_DIRECTORY
"${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg"LOGNAME install-${TARGET_TRIPLET}-dbg ) message(STATUS "Building ${TARGET_TRIPLET}-rel") vcpkg_execute_required_process(- COMMAND ${JOM} /K /J ${VCPKG_CONCURRENCY} /F makefile
install_dev
+ COMMAND ${JOM} /K /J ${VCPKG_CONCURRENCY} /F makefileinstall_devinstall_runtime
WORKING_DIRECTORY
"${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel"LOGNAME install-${TARGET_TRIPLET}-rel )portfile.cmake 2022-01-24 11:02:46.066088800 +0200 renamed from portfile.cmake.orig 2022-01-24 11:04:44.914467900 +0200 +1
-1@@ -129,13 +129,13 @@ else() message(STATUS "Building ${TARGET_TRIPLET}-dbg") vcpkg_execute_required_process( - COMMAND ${MAKE} -j ${VCPKG_CONCURRENCY} install_dev + COMMAND ${MAKE} -j ${VCPKG_CONCURRENCY} install_dev
install_runtime
WORKING_DIRECTORY
"${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg"LOGNAME install-${TARGET_TRIPLET}-dbg ) message(STATUS "Building ${TARGET_TRIPLET}-rel") vcpkg_execute_required_process(portfile.cmake 2022-01-24 11:02:46.066088800 +0200 renamed from portfile.cmake.orig 2022-01-24 11:04:44.914467900 +0200 +1
-1- COMMAND ${MAKE} -j ${VCPKG_CONCURRENCY} install_dev + COMMAND ${MAKE} -j ${VCPKG_CONCURRENCY} install_dev
install_runtime
WORKING_DIRECTORY
"${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel"LOGNAME install-${TARGET_TRIPLET}-rel )portfile.cmake 2022-01-24 11:02:46.066088800 +0200 renamed from portfile.cmake.orig 2022-01-24 11:04:44.914467900 +0200 +11
-0@@ -161,6 +161,17 @@ endif() +if(VCPKG_TARGET_IS_WINDOWS) + file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/tools/openssl/") + file(RENAME "${CURRENT_PACKAGES_DIR}/bin/openssl.exe" "${CURRENT_PACKAGES_DIR}/tools/openssl/openssl.exe") + + file(REMOVE + "${CURRENT_PACKAGES_DIR}/debug/bin/openssl.exe" + ) +endif() + +vcpkg_copy_tool_dependencies("${CURRENT_PACKAGES_DIR}/tools/openssl") + if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic") file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/lib/libcrypto.a""${CURRENT_PACKAGES_DIR}/debug/lib/libssl.a"
portfile.cmake 2022-01-24 11:02:46.066088800 +0200 line 198
Quoted 6 lines
portfile.cmake 2022-01-24 11:02:46.066088800 +0200 renamed from portfile.cmake.orig 2022-01-24 11:04:44.914467900 +0200 +1
-1@@ -184,4 +195,4 @@ ) file(INSTALL "${CURRENT_PORT_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" -) +)
A whole patch in the commit message is not very helpful and makes it hard to read. Why not include this patch + the original, and apply the patch during build?
Or just add a pointer to the original file in the changed file so that it could be diff-ed against if need be,
Quoted 6 lines
- use
sizeof(void *)since msvc doesn't support sizeof of function ptr- use
XKEY_PROV_PROPSmacro instead of props since msvc requires constant expression in aggregate initializers
These changes look sane though I think this should be a separate commit.
Selva
Hi,
Quoted 3 lines
A whole patch in the commit message is not very helpful and makes it hard to read. Why not include this patch + the original, and apply the patch during build?
Or just add a pointer to the original file in the changed file so that it could be diff-ed against if need be,
Yeah, I was not sure what is the best way to indicate difference between this one and original one, so I added it to commit message. Not sure what do you mean by "apply the patch during build" - you can have patches for port sources but I don't think you can patch the port script.
Like you proposed I could add a comment to the patched file which points to original one.
Quoted 1 line
These changes look sane though I think this should be a separate commit.
I could do that, but then commit without those changes will break the build.
Signature · 1 line
-Lev
Hi
Quoted 16 lines · Lev Stipakov
Hi,
Quoted 1 line
A whole patch in the commit message is not very helpful and makes it
hard to read. Why not include this patch + the original, and apply the patch during build?
Quoted 2 lines
Or just add a pointer to the original file in the changed file so that
it could be diff-ed against if need be,
Yeah, I was not sure what is the best way to indicate difference between this one and original one, so I added it to commit message. Not sure what do you mean by "apply the patch during build" - you can have patches for port sources but I don't think you can patch the port script.
Quoted 3 lines
Like you proposed I could add a comment to the patched file which points to original one.
As mentioned in my response to the GUI PR, I just can't bring myself to like this idea of matching vcpkg ports in OpenVPN core and GUI and the need to keep them in sync, keep them updated etc. Feels like a wrong approach though I do not know enough to suggest a better way.
Quoted 6 lines
Quoted 2 lines
These changes look sane though I think this should be a separate commit.
I could do that, but then commit without those changes will break the build.
Your fix to the xkey patch set is actually a generic one, not just a work-around for msvc. It could be applied first before fixing the msvc build.
Selva