-
Notifications
You must be signed in to change notification settings - Fork 30
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
Use readKeyFile to read both seed file and public key file #54
Conversation
Pull Request Test Coverage Report for Build 5373303424
💛 - Coveralls |
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.
Update copyright to 2018-2023 then I think it LGTM
Fixed |
It's consistent with the key reading behavior in `sign`, and we can add some comments in both seed file and public key file. And encode the signature with base64 url nopadding format instead of base64 std, since jwt signature is using base64 url nopadding format. So that `nk` command can be used to verify jwt token conviniently. Signed-off-by: JUN JIE NAN <[email protected]>
@@ -157,7 +157,7 @@ func sign(fname, keyFile string) { | |||
if err != nil { | |||
log.Fatal(err) | |||
} | |||
log.Printf("%s", base64.StdEncoding.EncodeToString(sigraw)) | |||
log.Printf("%s", base64.RawURLEncoding.EncodeToString(sigraw)) |
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.
Why the change here?
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.
Because in JWT three parts, header.payload.signature, the signature part is encoded in base64 url no padding format according JWT spec. If nk
uses base64 url no padding format as signature content, nk
command can be used to verify jwt token like this:
nk -verify header.payload -pubin pubin -sigfile signature
Or nk would compain illegle charset error.
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.
LGTM
It's consistent with the key reading behavior in
sign
, and we can add some comments in both seed file and public key file.