Skip to content

Commit ce60174

Browse files
committed
HTCONDOR-1290: Update Scitokens-cpp to openssl 3.0
-PR changes -Fixed Openssl 3.0 code to store public ec key correctly thus passing Unit tests -Set cmake option warnings equal errors to ON thus reverting to old behavior of failing to compile when a warning occurs -Implemented JWT-CPP patch into JWT v0.6.0 library included within vendor to allow for rpm building with older gcc versions -Reverted attempted fix for rpm building in .spec file due to compatability update added to JWT-CPP. No longer requires gcc v5.1 or greater
1 parent a5e1573 commit ce60174

File tree

4 files changed

+31
-6
lines changed

4 files changed

+31
-6
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ project( scitokens-cpp
88

99
option( SCITOKENS_BUILD_UNITTESTS "Build the scitokens-cpp unit tests" OFF )
1010
option( SCITOKENS_EXTERNAL_GTEST "Use an external/pre-installed copy of GTest" OFF )
11-
option( SCITOKENS_WARNINGS_ARE_ERRORS "Turn compiler warnings into build errors" OFF)
11+
option( SCITOKENS_WARNINGS_ARE_ERRORS "Turn compiler warnings into build errors" ON)
1212

1313
set( CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}" )
1414

rpm/scitokens-cpp.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Source0: https://github.com/scitokens/scitokens-cpp/releases/download/v%{version
1818
# inappropriate to include a "Provides", as jwt-cpp is not provided
1919
# by this package.
2020

21-
BuildRequires: gcc-c++ >= 5.1
21+
BuildRequires: gcc-c++
2222
BuildRequires: make
2323
BuildRequires: cmake3
2424
BuildRequires: sqlite-devel

src/scitokens_internal.cpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -623,14 +623,29 @@ scitokens::Validator::store_public_ec_key(const std::string &issuer, const std::
623623
throw UnsupportedKeyException("Unable to get OpenSSL EC group");
624624
}
625625

626-
std::unique_ptr<EC_POINT, decltype(&EC_POINT_free)> Q_point(EC_POINT_new(ec_group.get()), EC_POINT_free);
627-
if (!Q_point.get()) {
626+
std::unique_ptr<EC_POINT, decltype(&EC_POINT_free)> q_point(EC_POINT_new(ec_group.get()), EC_POINT_free);
627+
if (!q_point.get()) {
628628
throw UnsupportedKeyException("Unable to get OpenSSL EC point");
629629
}
630630

631-
if (!EC_POINT_get_affine_coordinates(ec_group.get(), Q_point.get(), x_bignum.get(), y_bignum.get(), NULL)) {
631+
OSSL_PARAM *params;
632+
if (!EVP_PKEY_todata(pkey.get(), EVP_PKEY_PUBLIC_KEY, &params)) {
633+
throw UnsupportedKeyException("Unable to get OpenSSL public key parameters");
634+
}
635+
636+
void* buf = NULL;
637+
size_t buf_len, max_len = 256;
638+
OSSL_PARAM *p = OSSL_PARAM_locate(params,"pub");
639+
if (!p || !OSSL_PARAM_get_octet_string(p, &buf, max_len, &buf_len)
640+
|| !EC_POINT_oct2point(ec_group.get(), q_point.get(), static_cast<unsigned char*>(buf), buf_len, nullptr)) {
641+
throw UnsupportedKeyException("Failed to to set OpenSSL EC point with public key information");
642+
}
643+
644+
if (!EC_POINT_get_affine_coordinates(ec_group.get(), q_point.get(), x_bignum.get(), y_bignum.get(), NULL)) {
632645
throw UnsupportedKeyException("Unable to get OpenSSL affine coordinates");
633646
}
647+
648+
OSSL_PARAM_free(params);
634649
#else
635650
std::unique_ptr<EC_KEY, decltype(&EC_KEY_free)> pkey
636651
(PEM_read_bio_EC_PUBKEY(pubkey_bio.get(), nullptr, nullptr, nullptr), EC_KEY_free);

vendor/jwt-cpp/include/jwt-cpp/jwt.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
#include <algorithm>
2424
#include <chrono>
25-
#include <codecvt>
2625
#include <functional>
2726
#include <iterator>
2827
#include <locale>
@@ -34,6 +33,10 @@
3433
#include <utility>
3534
#include <vector>
3635

36+
#if __cplusplus > 201103L
37+
#include <codecvt>
38+
#endif
39+
3740
#if __cplusplus >= 201402L
3841
#ifdef __has_include
3942
#if __has_include(<experimental/type_traits>)
@@ -3053,11 +3056,18 @@ namespace jwt {
30533056
}
30543057

30553058
static std::string to_lower_unicode(const std::string& str, const std::locale& loc) {
3059+
#if __cplusplus > 201103L
30563060
std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> conv;
30573061
auto wide = conv.from_bytes(str);
30583062
auto& f = std::use_facet<std::ctype<wchar_t>>(loc);
30593063
f.tolower(&wide[0], &wide[0] + wide.size());
30603064
return conv.to_bytes(wide);
3065+
#else
3066+
std::string result;
3067+
std::transform(str.begin(), str.end(), std::back_inserter(result),
3068+
[&loc](unsigned char c) { return std::tolower(c, loc); });
3069+
return result;
3070+
#endif
30613071
}
30623072
};
30633073
} // namespace verify_ops

0 commit comments

Comments
 (0)