Merge branch 'master' into master

This commit is contained in:
Chris Mc
2020-04-07 17:38:40 -04:00
committed by GitHub
2 changed files with 6 additions and 6 deletions

View File

@@ -31,7 +31,7 @@ target_link_libraries(jwt-cpp INTERFACE OpenSSL::SSL OpenSSL::Crypto)
set(JWT_HEADERS ${JWT_INCLUDE_PATH}/jwt-cpp/base.h
${JWT_INCLUDE_PATH}/jwt-cpp/jwt.h)
if(EXTERNAL_PICOJSON)
if(NOT EXTERNAL_PICOJSON)
set(PICO_HEADER ${JWT_INCLUDE_PATH}/picojson/picojson.h)
endif()
@@ -49,7 +49,7 @@ write_basic_package_version_file(
COMPATIBILITY ExactVersion)
install(FILES ${JWT_HEADERS} DESTINATION include/jwt-cpp)
if(EXTERNAL_PICOJSON)
if(NOT EXTERNAL_PICOJSON)
install(FILES ${PICO_HEADER} DESTINATION include/picojson)
endif()

View File

@@ -75,7 +75,7 @@ namespace jwt {
inline
std::string extract_pubkey_from_cert(const std::string& certstr, const std::string& pw = "") {
// TODO: Cannot find the exact version this change happended
#if OPENSSL_VERSION_NUMBER <= 0x1000114fL
#if OPENSSL_VERSION_NUMBER <= 0x10100003L
std::unique_ptr<BIO, decltype(&BIO_free_all)> certbio(BIO_new_mem_buf(const_cast<char*>(certstr.data()), certstr.size()), BIO_free_all);
#else
std::unique_ptr<BIO, decltype(&BIO_free_all)> certbio(BIO_new_mem_buf(certstr.data(), certstr.size()), BIO_free_all);
@@ -337,16 +337,16 @@ namespace jwt {
if (!private_key.empty()) {
std::unique_ptr<BIO, decltype(&BIO_free_all)> privkey_bio(BIO_new(BIO_s_mem()), BIO_free_all);
if ((size_t)BIO_write(privkey_bio.get(), private_key.data(), private_key.size()) != private_key.size())
throw rsa_exception("failed to load private key: bio_write failed");
throw ecdsa_exception("failed to load private key: bio_write failed");
pkey.reset(PEM_read_bio_ECPrivateKey(privkey_bio.get(), nullptr, nullptr, const_cast<char*>(private_key_password.c_str())), EC_KEY_free);
if (!pkey)
throw rsa_exception("failed to load private key: PEM_read_bio_ECPrivateKey failed");
throw ecdsa_exception("failed to load private key: PEM_read_bio_ECPrivateKey failed");
size_t keysize = EC_GROUP_get_degree(EC_KEY_get0_group(pkey.get()));
if(keysize != signature_length*4 && (signature_length != 132 || keysize != 521))
throw ecdsa_exception("invalid key size");
}
if(!pkey)
throw rsa_exception("at least one of public or private key need to be present");
throw ecdsa_exception("at least one of public or private key need to be present");
if(EC_KEY_check_key(pkey.get()) == 0)
throw ecdsa_exception("failed to load key: key is invalid");