Skip to content

Commit

Permalink
sort signing keys on marshal
Browse files Browse the repository at this point in the history
  • Loading branch information
sethjback committed Aug 21, 2023
1 parent c4f1fd0 commit 083d206
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions v2/signingkeys.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"encoding/json"
"errors"
"fmt"
"sort"

"github.com/nats-io/nkeys"
)
Expand Down Expand Up @@ -124,10 +125,14 @@ func (sk *SigningKeys) MarshalJSON() ([]byte, error) {
if sk == nil {
return nil, nil
}

keys := sk.Keys()
sort.Strings(keys)

var a []interface{}
for k, v := range *sk {
if v != nil {
a = append(a, v)
for _, k := range keys {
if (*sk)[k] != nil {
a = append(a, (*sk)[k])
} else {
a = append(a, k)
}
Expand Down

0 comments on commit 083d206

Please sign in to comment.