Skip to content

Commit

Permalink
Make sure we set the EdDSA algo on the jwk (#45)
Browse files Browse the repository at this point in the history
This way the later code can fetch the value via Algorithm().
  • Loading branch information
eest authored Feb 20, 2025
1 parent 29e57b5 commit 4251771
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 1 addition & 2 deletions pkg/runner/mqtt.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/eclipse/paho.golang/autopaho"
"github.com/eclipse/paho.golang/autopaho/queue/file"
"github.com/eclipse/paho.golang/paho"
"github.com/lestrrat-go/jwx/v2/jwa"
"github.com/lestrrat-go/jwx/v2/jwk"
"github.com/lestrrat-go/jwx/v2/jws"
)
Expand Down Expand Up @@ -113,7 +112,7 @@ func (edm *dnstapMinimiser) runAutoPaho(cm *autopaho.ConnectionManager, topic st
return
}

signedMsg, err := jws.Sign(unsignedMsg, jws.WithJSON(), jws.WithKey(jwa.ES256, mqttJWK))
signedMsg, err := jws.Sign(unsignedMsg, jws.WithJSON(), jws.WithKey(mqttJWK.Algorithm(), mqttJWK))
if err != nil {
edm.log.Error("runAutoPaho: failed to created JWS message", "error", err)
continue
Expand Down
6 changes: 6 additions & 0 deletions pkg/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
"github.com/fsnotify/fsnotify"
_ "github.com/grafana/pyroscope-go/godeltaprof/http/pprof" // revive linter: keep blank import close to where it is used for now.
lru "github.com/hashicorp/golang-lru/v2"
"github.com/lestrrat-go/jwx/v2/jwa"
"github.com/lestrrat-go/jwx/v2/jwk"
"github.com/miekg/dns"
"github.com/prometheus/client_golang/prometheus"
Expand Down Expand Up @@ -531,6 +532,11 @@ func (edm *dnstapMinimiser) setupMQTT(mqttClientCertStore *certStore) {
edm.log.Error("unable to create MQTT JWK key", "error", err)
os.Exit(1)
}
err = mqttJWK.Set(jwk.AlgorithmKey, jwa.EdDSA)
if err != nil {
edm.log.Error("unable to set MQTT JWK `alg`", "error", err)
os.Exit(1)
}

err = mqttJWK.Set(jwk.KeyIDKey, viper.GetString("mqtt-signing-key-id"))
if err != nil {
Expand Down

0 comments on commit 4251771

Please sign in to comment.