Why does unmarshalling into a jose.JSONWebKeySet fail in a traefik plugin but work correctly outside?
import (
...
"github.com/go-jose/go-jose/v3"
...
)
func test() {
response, err := http.Get("https://www.googleapis.com/oauth2/v3/certs")
if err != nil {
log.Printf("error fetching: %s", err)
return
}
if response.StatusCode != http.StatusOK {
log.Printf("unexpected status: %d", response.StatusCode)
return
}
var keys jose.JSONWebKeySet
err = json.NewDecoder(response.Body).Decode(&keys)
if err != nil {
log.Printf("error decoding: %s", err)
return
}
log.Printf("Count:%d", len(keys.Keys))
for _, key := range keys.Keys {
log.Printf("KeyID:%s Key:%s", key.KeyID, key.Key)
}
}
Output outside traefik
Count:2
KeyID:7c9c78e3b00e1bb092d246c887b11220c87b7d20 Key:&{20752000742878626208251236088601222372521671134543580397608485823168275204394566381471942568181383543342300807545712698306353257600926079070991388714775222134270874007625062285467089663179852821558839098858413194224164054043006929976331092825954525247914289534510084931384398503426330581925456175406334406251329771069819829469786314782883136771059411227363227992482047538939793216772945875122715578875114755870706802192307156544412133006291145792110767902874128682405874535891261895774682962447479106829453813603072185067410317087675120711404000138518104597515454632775419515741849612869135041120618641648994340888633 %!s(int=65537)}
KeyID:c3afe7a9bda46bae6ef97e46c95cda48912e5979 Key:&{21595602583112691651187633380904188650705001214859492355525774050769654556924674294316420340830934280848768926279639709490083501991048223126642925439478642322340155493527521164723662221121763538517106154170920532193697691833279115617524956750830919614583220135390609099184049432467470765726064225761723362014971481683641020052860416877357370668072045629018839013451791049143659685258105035102069906628588773212272353053243195975722052760610933537804309986031096987008856749118008290898958159963953026976573268290101371690120563532710201058654260320342998802360012576926616513577436651562588694147847445342102332106999 %!s(int=65537)}
Output in plugin
traefik_proxy.1.p4ytfe8zcwql@docker-desktop | time="2023-08-22T15:03:33Z" level=error msg="Count:2" plugin=plugin-test module=github.com/agilezebra/test
traefik_proxy.1.p4ytfe8zcwql@docker-desktop | time="2023-08-22T15:03:33Z" level=error msg="KeyID: Key:%!s(<nil>)" plugin=plugin-test module=github.com/agilezebra/test
traefik_proxy.1.p4ytfe8zcwql@docker-desktop | time="2023-08-22T15:03:33Z" level=error msg="KeyID: Key:%!s(<nil>)" plugin=plugin-test module=github.com/agilezebra/test