-
Notifications
You must be signed in to change notification settings - Fork 50
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
Implement elementary .pem
keyfile parsing.
#62
Conversation
e.g. `jose jws sig -p ~/gcloud.pem -I payload.json`
Codecov Report
@@ Coverage Diff @@
## master #62 +/- ##
=========================================
- Coverage 77.75% 77.25% -0.5%
=========================================
Files 60 60
Lines 5794 5720 -74
=========================================
- Hits 4505 4419 -86
- Misses 1289 1301 +12
Continue to review full report at Codecov.
|
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 PR. Apart from suggested changes, is it possible to add a test in file: "tests/jose-jws-sig "to handle this?
} else { | ||
FILE_AUTO *file = fopen(arg, "r"); | ||
// TODO: encrypted key callback for password. | ||
if (!(file && PEM_read_PrivateKey(file, &pkey, NULL, NULL))) |
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.
Here, it is not distinguished the case of !file vs the case of PEM_read_PrivateKey.
Distinguish between them, so that if the error has to do with PEM_read_PrivateKey, then fclose on file is done
@@ -84,6 +84,12 @@ static const jcmd_doc_t jcmd_doc_key[] = { | |||
{} | |||
}; | |||
|
|||
static const jcmd_doc_t jcmd_doc_pem[] = { | |||
{ .arg = "FILE", .doc="Import JWK from '.PEM' FILE" }, |
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.
is it required for the file to be ".PEM"? Why not just "Import JWK from FILE"?
@@ -84,6 +84,12 @@ static const jcmd_doc_t jcmd_doc_key[] = { | |||
{} | |||
}; | |||
|
|||
static const jcmd_doc_t jcmd_doc_pem[] = { | |||
{ .arg = "FILE", .doc="Import JWK from '.PEM' FILE" }, | |||
{ .arg = "-", .doc="Import JWK from '.PEM' on standard input" }, |
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.
I think "Import JWK from standard input" fits better
Relatively untested
.pem
parsing for RS256, etc.Useful perhaps for RS256 per https://cloud.google.com/iot/docs/how-tos/credentials/jwts
See Also #39
Example
jose jws sig -I payload.json -p ~/gcloud.pem
File Contents
payload.json
gcloud.pem