diff --git a/include/jwt-cpp/jwt.h b/include/jwt-cpp/jwt.h index a3d369634..25e1440dd 100644 --- a/include/jwt-cpp/jwt.h +++ b/include/jwt-cpp/jwt.h @@ -494,44 +494,41 @@ namespace jwt { #endif }; - namespace details { - inline std::unique_ptr make_mem_buf_bio() { - return std::unique_ptr(BIO_new(BIO_s_mem()), BIO_free_all); - } + inline std::unique_ptr make_mem_buf_bio() { + return std::unique_ptr(BIO_new(BIO_s_mem()), BIO_free_all); + } - inline std::unique_ptr make_mem_buf_bio(const std::string& data) { - return std::unique_ptr( + inline std::unique_ptr make_mem_buf_bio(const std::string& data) { + return std::unique_ptr( #if OPENSSL_VERSION_NUMBER <= 0x10100003L - BIO_new_mem_buf(const_cast(data.data()), static_cast(data.size())), BIO_free_all + BIO_new_mem_buf(const_cast(data.data()), static_cast(data.size())), BIO_free_all #else - BIO_new_mem_buf(data.data(), static_cast(data.size())), BIO_free_all + BIO_new_mem_buf(data.data(), static_cast(data.size())), BIO_free_all #endif - ); - } + ); + } - template - std::string write_bio_to_string(std::unique_ptr& bio_out, - std::error_code& ec) { - char* ptr = nullptr; - auto len = BIO_get_mem_data(bio_out.get(), &ptr); - if (len <= 0 || ptr == nullptr) { - ec = error_category::convert_to_pem_failed; - return {}; - } - return {ptr, static_cast(len)}; + template + std::string write_bio_to_string(std::unique_ptr& bio_out, std::error_code& ec) { + char* ptr = nullptr; + auto len = BIO_get_mem_data(bio_out.get(), &ptr); + if (len <= 0 || ptr == nullptr) { + ec = error_category::convert_to_pem_failed; + return {}; } + return {ptr, static_cast(len)}; + } - inline std::unique_ptr make_evp_md_ctx() { - return + inline std::unique_ptr make_evp_md_ctx() { + return #ifdef JWT_OPENSSL_1_0_0 - std::unique_ptr(EVP_MD_CTX_create(), - &EVP_MD_CTX_destroy); + std::unique_ptr(EVP_MD_CTX_create(), &EVP_MD_CTX_destroy); #else - std::unique_ptr(EVP_MD_CTX_new(), &EVP_MD_CTX_free); + std::unique_ptr(EVP_MD_CTX_new(), &EVP_MD_CTX_free); #endif - } + } - /** + /** * \brief Extract the public key of a pem certificate * * \tparam error_category jwt::error enum category to match with the keys being used