Skip to content

Commit 97c8782

Browse files
🔐 Make it possible to build with OpenSSL 1.0.1 (#199)
* Make it possible to build with OpenSSL 1.0.1 This patch updates the code in the jwt-cpp/jwt.h header and relaxes the requirement for OpenSSL's version in the top-level CMakeLists.txt to allow for compiling with OpenSSL 1.0.1. The patch works around the non-constantness of the 'sig' parameter in the signature of the EVP_DigestVerifyFinal() function in versions of OpenSSL prior to 1.0.2. I verfied it's now possible to compile with OpenSSL 1.0.1, but I guess it might be possible to compile even with OpenSSL 1.0.0 after tweaking the version requirement in CMakeLists.txt. The new EVP_DigestVerifyFinal() signature was introduced in [1] and then cherry-picked into the main branch as [2]. The update [1] doesn't contain any functional change per se: even prior to the update, EVP_DigestVerifyFinal() implementation was de facto treating the 'sig' parameter as if it were immutable [3]. [1] openssl/openssl@1abfa78 [2] openssl/openssl@0f7fa1b [3] https://github.com/openssl/openssl/blob/27007233db5d6f8b91ed474c4e09dd7014871cc6/crypto/evp/m_sigver.c#L163-L187 * Fix formatting in jwt-cpp/jwt.h This patch doesn't contain any functional modifications. This is a follow-up to d74c832. * Test against OpenSSL 1.0.1u Co-authored-by: Chris Mc <prince.chrismc@gmail.com>
1 parent e6b92cc commit 97c8782

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

.github/workflows/ssl.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jobs:
1616
- { tag: "OpenSSL_1_1_1l", name: "1.1.1l" }
1717
- { tag: "OpenSSL_1_1_0i", name: "1.1.0i" }
1818
- { tag: "OpenSSL_1_0_2u", name: "1.0.2u" }
19+
- { tag: "OpenSSL_1_0_1u", name: "1.0.1u" }
1920
name: OpenSSL ${{ matrix.openssl.name }}
2021
steps:
2122
- uses: actions/checkout@v2

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ endif()
4949

5050
# Lookup dependencies
5151
if(${JWT_SSL_LIBRARY} MATCHES "OpenSSL")
52-
find_package(OpenSSL 1.0.2 REQUIRED)
52+
find_package(OpenSSL 1.0.1 REQUIRED)
5353
elseif(${JWT_SSL_LIBRARY} MATCHES "LibreSSL")
5454
find_package(LibreSSL 3.0.0 REQUIRED)
5555
elseif(${JWT_SSL_LIBRARY} MATCHES "wolfSSL")

include/jwt-cpp/jwt.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,9 +1088,13 @@ namespace jwt {
10881088
return;
10891089
}
10901090

1091+
#if OPENSSL_VERSION_NUMBER < 0x10002000L
1092+
unsigned char* der_sig_data = reinterpret_cast<unsigned char*>(const_cast<char*>(der_signature.data()));
1093+
#else
1094+
const unsigned char* der_sig_data = reinterpret_cast<const unsigned char*>(der_signature.data());
1095+
#endif
10911096
auto res =
1092-
EVP_DigestVerifyFinal(ctx.get(), reinterpret_cast<const unsigned char*>(der_signature.data()),
1093-
static_cast<unsigned int>(der_signature.length()));
1097+
EVP_DigestVerifyFinal(ctx.get(), der_sig_data, static_cast<unsigned int>(der_signature.length()));
10941098
if (res == 0) {
10951099
ec = error::signature_verification_error::invalid_signature;
10961100
return;

0 commit comments

Comments
 (0)