@@ -858,15 +858,15 @@ namespace jwt {
858
858
public:
859
859
static key symmetric (const std::string& bytes) { return key (bytes); }
860
860
861
- static key asymmetric (std::shared_ptr<EVP_PKEY> pkey) { return key (pkey); }
861
+ static key asymmetric (helper::evp_pkey_handle pkey) { return key (pkey); }
862
862
863
863
std::string get_symmetric_key () const {
864
864
if (!is_symmetric) { throw std::logic_error (" not a symmetric key" ); }
865
865
866
866
return oct_key;
867
867
}
868
868
869
- std::shared_ptr<EVP_PKEY> get_asymmetric_key () const {
869
+ helper::evp_pkey_handle get_asymmetric_key () const {
870
870
if (is_symmetric) { throw std::logic_error (" not an asymmetric key" ); }
871
871
872
872
return pkey;
@@ -878,13 +878,13 @@ namespace jwt {
878
878
oct_key = key;
879
879
}
880
880
881
- key (std::shared_ptr<EVP_PKEY> key) {
881
+ key (helper::evp_pkey_handle key) {
882
882
is_symmetric = false ;
883
883
pkey = key;
884
884
}
885
885
886
886
bool is_symmetric;
887
- std::shared_ptr<EVP_PKEY> pkey;
887
+ helper::evp_pkey_handle pkey;
888
888
std::string oct_key;
889
889
};
890
890
@@ -3896,7 +3896,8 @@ namespace jwt {
3896
3896
using iterator = typename jwt_vector_t ::iterator;
3897
3897
using const_iterator = typename jwt_vector_t ::const_iterator;
3898
3898
3899
- JWT_CLAIM_EXPLICIT jwks (const typename json_traits::string_type& str) {
3899
+ template <typename Decode>
3900
+ jwks (const typename json_traits::string_type& str, Decode decode) {
3900
3901
typename json_traits::value_type parsed_val;
3901
3902
if (!json_traits::parse (parsed_val, str)) throw error::invalid_json_exception ();
3902
3903
@@ -3905,9 +3906,16 @@ namespace jwt {
3905
3906
3906
3907
auto jwk_list = jwks_json.get_claim (" keys" ).as_array ();
3907
3908
std::transform (jwk_list.begin (), jwk_list.end (), std::back_inserter (jwk_claims),
3908
- [](const typename json_traits::value_type& val) { return jwk_t { val} ; });
3909
+ [& ](const typename json_traits::value_type& val) { return jwk_t ( val, decode) ; });
3909
3910
}
3910
3911
3912
+ #ifndef JWT_DISABLE_BASE64
3913
+ JWT_CLAIM_EXPLICIT jwks (const typename json_traits::string_type& str)
3914
+ : jwks(str, [](const typename json_traits::string_type& str) {
3915
+ return base::decode<alphabet::base64url>(base::pad<alphabet::base64url>(str));
3916
+ }) {}
3917
+ #endif
3918
+
3911
3919
iterator begin () { return jwk_claims.begin (); }
3912
3920
iterator end () { return jwk_claims.end (); }
3913
3921
const_iterator cbegin () const { return jwk_claims.begin (); }
0 commit comments