Skip to content
This repository has been archived by the owner on May 21, 2022. It is now read-only.

Simplify control flow #418

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 9 additions & 18 deletions cmd/jwt/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,25 +210,16 @@ func signToken() error {
token.Header[k] = v
}
}

if isEs() {
if k, ok := key.([]byte); !ok {
return fmt.Errorf("Couldn't convert key data to key")
} else {
key, err = jwt.ParseECPrivateKeyFromPEM(k)
if err != nil {
return err
}
}
} else if isRs() {
if k, ok := key.([]byte); !ok {

if k, ok := key.([]byte); !ok {
return fmt.Errorf("Couldn't convert key data to key")
} else {
key, err = jwt.ParseRSAPrivateKeyFromPEM(k)
if err != nil {
return err
}
}
} else if isEs() {
key, err = jwt.ParseECPrivateKeyFromPEM(k)
} else if isRS() {
key, err = jwt.ParseRSAPrivateKeyFromPEM(k)
}
if err != nil {
return err
}

if out, err := token.SignedString(key); err == nil {
Expand Down