-
-
Notifications
You must be signed in to change notification settings - Fork 243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improvements to key loading helpers #186
Comments
Orignally posted in #185 (comment) |
The newer EC family of helpers are also missing test code which was present with the old ones |
The implementations are nearly the same they just need different error codes but otherwise are interchangable diff --git a/include/jwt-cpp/jwt.h b/include/jwt-cpp/jwt.h
index 000fb0b..1235585 100644
--- a/include/jwt-cpp/jwt.h
+++ b/include/jwt-cpp/jwt.h
@@ -778,7 +778,7 @@ namespace jwt {
ec.clear();
auto pubkey_bio = make_mem_buf_bio();
if (!pubkey_bio) {
- ec = error::ecdsa_error::create_mem_bio_failed;
+ ec = error::rsa_error::create_mem_bio_failed;
return {};
}
if (key.substr(0, 27) == "-----BEGIN CERTIFICATE-----") {
@@ -786,13 +786,13 @@ namespace jwt {
if (ec) return {};
const int len = static_cast<int>(epkey.size());
if (BIO_write(pubkey_bio.get(), epkey.data(), len) != len) {
- ec = error::ecdsa_error::load_key_bio_write;
+ ec = error::rsa_error::load_key_bio_write;
return {};
}
} else {
const int len = static_cast<int>(key.size());
if (BIO_write(pubkey_bio.get(), key.data(), len) != len) {
- ec = error::ecdsa_error::load_key_bio_write;
+ ec = error::rsa_error::load_key_bio_write;
return {};
}
}
@@ -800,7 +800,7 @@ namespace jwt {
evp_pkey_handle pkey(PEM_read_bio_PUBKEY(
pubkey_bio.get(), nullptr, nullptr,
(void*)password.data())); // NOLINT(google-readability-casting) requires `const_cast`
- if (!pkey) ec = error::ecdsa_error::load_key_bio_read;
+ if (!pkey) ec = error::rsa_error::load_key_bio_read;
return pkey;
}
|
Should be possible with some more templates compiler explorer |
We should deprecate/remove the older helpers and rename them to have RSA in the name.
Originally posted by @prince-chrismc in #185 (comment)
The text was updated successfully, but these errors were encountered: