-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
New Operations: JWK conversion from/to PEM #1277
Conversation
cd44317
to
e76eef9
Compare
Updated to current sources, added some more tests and fixed some conversion problems |
Rebased to the current sources. Looks like there is something wrong with the UI tests:
|
Rebased to the current master sources. This fixes #1794 |
if (Array.isArray(inputJson)) { | ||
// list of keys => transform all keys | ||
keys = inputJson; | ||
} else if (Array.isArray(inputJson.keys)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like a variety of examples / documentation also uses jwk
as a paramater to store an array of keys, e.g:
{"jwk":
[
{"alg":"EC",
"crv":"P-256",
"x":"MKBCTNIcKUSDii11ySs3526iDZ8AiTo7Tu6KPAqv7D4",
"y":"4Etl6SRW2YiLUrN5vfvVHuhp7x8PxltmWWlbbM4IFyM",
"use":"enc",
"kid":"1"},
{"alg":"RSA",
"mod": "0vx7agoebGcQSuuPiLJXZptN9nndrQmbXEps2aiAFbWhM78LhWx
4cbbfAAtVT86zwu1RK7aPFFxuhDR1L6tSoc_BJECPebWKRXjBZCiFV4n3oknjhMs
tn64tZ_2W-5JsGY4Hc5n9yBXArwl93lqt7_RN5w6Cf0h4QyQ5v-65YGjQR0_FDW2
QvzqY368QQMicAtaSqzs8KJZgnYb9c7d0zgdAZHzu6qMQvRL5hajrn1n91CbOpbI
SD08qNLyrdkt-bFTWhAI4vMQFh6WeZu0fM4lFd2NcRwr3XPksINHaQ-G_xBniIqb
w0Ls1jF44-csFCur-kEgU8awapJzKnqDKgw",
"exp":"AQAB",
"kid":"2011-04-29"}
]
}
Might be a nice addition. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the RFC ( https://datatracker.ietf.org/doc/html/rfc7517#section-5 ) it is "keys". So it should hopefully match most use cases.
Tried it out with a few JWKs and a few PEMs. This is a nice implementation! Thanks so much for the contribution, apologies it's taken three years to merge this in. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the merge
if (Array.isArray(inputJson)) { | ||
// list of keys => transform all keys | ||
keys = inputJson; | ||
} else if (Array.isArray(inputJson.keys)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the RFC ( https://datatracker.ietf.org/doc/html/rfc7517#section-5 ) it is "keys". So it should hopefully match most use cases.
Transforms a key in PEM format to a JSON Web key or
a JWK back to its PEM format