Skip to content

Commit 0884647

Browse files
committed
Add support for OpenSSL 1.1.
Mostly just avoiding direct access of internal structures.
1 parent 9e452aa commit 0884647

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,18 @@ elseif( UNIX )
3131

3232
include (FindPkgConfig)
3333
pkg_check_modules(LIBCRYPTO REQUIRED libcrypto)
34+
pkg_check_modules(OPENSSL REQUIRED openssl)
3435
pkg_check_modules(SQLITE REQUIRED sqlite3)
3536

37+
# pkg_check_modules fails to return an absolute path on RHEL7. Set the
38+
# link directories accordingly.
39+
link_directories(${OPENSSL_LIBRARY_DIRS} ${LIBCRYPTO_LIBRARY_DIRS})
3640
endif()
3741

38-
include_directories( "${PROJECT_SOURCE_DIR}" ${JWT_CPP_INCLUDES} ${CURL_INCLUDES} ${LIBCRYPTO_INCLUDE_DIRS} ${SQLITE_INCLUDE_DIRS} ${UUID_INCLUDE_DIRS} )
42+
include_directories( "${PROJECT_SOURCE_DIR}" ${JWT_CPP_INCLUDES} ${CURL_INCLUDES} ${OPENSSL_INCLUDE_DIRS} ${LIBCRYPTO_INCLUDE_DIRS} ${SQLITE_INCLUDE_DIRS} ${UUID_INCLUDE_DIRS} )
3943

4044
add_library(SciTokens SHARED src/scitokens.cpp src/scitokens_internal.cpp src/scitokens_cache.cpp)
41-
target_link_libraries(SciTokens ${LIBCRYPTO_LIBRARIES} ${CURL_LIBRARIES} ${SQLITE_LIBRARIES} ${UUID_LIBRARIES})
45+
target_link_libraries(SciTokens ${OPENSSL_LIBRARIES} ${LIBCRYPTO_LIBRARIES} ${CURL_LIBRARIES} ${SQLITE_LIBRARIES} ${UUID_LIBRARIES})
4246

4347
if ( NOT APPLE AND UNIX )
4448
set_target_properties(SciTokens PROPERTIES LINK_FLAGS "-Wl,--version-script=${PROJECT_SOURCE_DIR}/configs/export-symbols")

src/scitokens_internal.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,13 @@ rs256_from_coords(const std::string &e_str, const std::string &n_str) {
238238
std::unique_ptr<BIGNUM, decltype(&BN_free)> n_bignum(BN_bin2bn(reinterpret_cast<const unsigned char *>(n_decode.c_str()), n_decode.size(), nullptr), BN_free);
239239

240240
std::unique_ptr<RSA, decltype(&RSA_free)> rsa(RSA_new(), RSA_free);
241+
#if OPENSSL_VERSION_NUMBER < 0x10100000L
241242
rsa->e = e_bignum.get();
242243
rsa->n = n_bignum.get();
243244
rsa->d = nullptr;
245+
#else
246+
RSA_set0_key(rsa.get(), n_bignum.get(), e_bignum.get(), nullptr);
247+
#endif
244248
e_bignum.release();
245249
n_bignum.release();
246250

0 commit comments

Comments
 (0)