@@ -858,15 +858,15 @@ namespace jwt {
858858 public:
859859 static key symmetric (const std::string& bytes) { return key (bytes); }
860860
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); }
862862
863863 std::string get_symmetric_key () const {
864864 if (!is_symmetric) { throw std::logic_error (" not a symmetric key" ); }
865865
866866 return oct_key;
867867 }
868868
869- std::shared_ptr<EVP_PKEY> get_asymmetric_key () const {
869+ helper::evp_pkey_handle get_asymmetric_key () const {
870870 if (is_symmetric) { throw std::logic_error (" not an asymmetric key" ); }
871871
872872 return pkey;
@@ -878,13 +878,13 @@ namespace jwt {
878878 oct_key = key;
879879 }
880880
881- key (std::shared_ptr<EVP_PKEY> key) {
881+ key (helper::evp_pkey_handle key) {
882882 is_symmetric = false ;
883883 pkey = key;
884884 }
885885
886886 bool is_symmetric;
887- std::shared_ptr<EVP_PKEY> pkey;
887+ helper::evp_pkey_handle pkey;
888888 std::string oct_key;
889889 };
890890
@@ -3896,7 +3896,8 @@ namespace jwt {
38963896 using iterator = typename jwt_vector_t ::iterator;
38973897 using const_iterator = typename jwt_vector_t ::const_iterator;
38983898
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) {
39003901 typename json_traits::value_type parsed_val;
39013902 if (!json_traits::parse (parsed_val, str)) throw error::invalid_json_exception ();
39023903
@@ -3905,9 +3906,16 @@ namespace jwt {
39053906
39063907 auto jwk_list = jwks_json.get_claim (" keys" ).as_array ();
39073908 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) ; });
39093910 }
39103911
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+
39113919 iterator begin () { return jwk_claims.begin (); }
39123920 iterator end () { return jwk_claims.end (); }
39133921 const_iterator cbegin () const { return jwk_claims.begin (); }
0 commit comments