Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
prince-chrismc authored Apr 7, 2020
2 parents 6793369 + 5afe5a7 commit bb5df74
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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()

Expand Down
8 changes: 4 additions & 4 deletions include/jwt-cpp/jwt.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit bb5df74

Please sign in to comment.