Azure Service Bus UnauthorizedError: InvalidSignature: The token has an invalid signature inside Kubernetes cluster

1/8/2019

I'm getting an error:

UnauthorizedError: InvalidSignature: The token has an invalid signature

when I'm trying to access Azure Service Bus from a nodejs docker container running inside Kubernetes cluster in Azure.

Interesting to note that I don't get this error when I run the code locally, or just inside the docker container on my dev laptop but as soon as I deploy container to K8 cluster I'm getting that error.

I verified the service-bus SAS primary key is correct inside K8 cluster secrets file.

Here's how error object looks like inside K8 cluster:

UnauthorizedError: InvalidSignature: The token has an invalid signature. {"timestamp":"2019-01-08T05:43:48.918Z"}
debug: condition: com.microsoft:auth-failed {"timestamp":"2019-01-08T05:43:48.920Z"}
debug: info: undefined {"timestamp":"2019-01-08T05:43:48.920Z"}
debug: message: InvalidSignature: The token has an invalid signature. {"timestamp":"2019-01-08T05:43:48.924Z"}
debug: name: UnauthorizedError {"timestamp":"2019-01-08T05:43:48.924Z"}
debug: retryable: false {"timestamp":"2019-01-08T05:43:48.924Z"}
debug: stack: UnauthorizedError: InvalidSignature: The token has an invalid signature.
    at Object.translate (/usr/src/app/node_modules/@azure/amqp-common/dist/lib/errors.js:527:17)
    at Receiver.messageCallback (/usr/src/app/node_modules/@azure/amqp-common/dist/lib/requestResponseLink.js:109:44)
    at Receiver.emit (events.js:182:13)
    at emit (/usr/src/app/node_modules/rhea-promise/dist/lib/util/utils.js:129:24)
    at Object.emitEvent (/usr/src/app/node_modules/rhea-promise/dist/lib/util/utils.js:140:9)
    at Receiver._link.on (/usr/src/app/node_modules/rhea-promise/dist/lib/link.js:249:25)
    at Receiver.emit (events.js:182:13)
    at Receiver.link.dispatch (/usr/src/app/node_modules/rhea/lib/link.js:59:37)
    at Incoming.on_transfer (/usr/src/app/node_modules/rhea/lib/session.js:360:22)
    at Session.on_transfer (/usr/src/app/node_modules/rhea/lib/session.js:736:19) {"timestamp":"2019-01-08T05:43:48.925Z"}
debug: translated: true {"timestamp":"2019-01-08T05:43:48.925Z"}

I'm using @azure/service-bus as a node package to work with azure service bus.

Any help, suggestions or ideas highly appreciated.

Thank you very one.

-- Dmitry Lukianenko
azure
azure-servicebus-topics
azureservicebus
docker
kubernetes

1 Answer

1/8/2019

in this case the issue was with the way OP passes the SAS string to the container

-- 4c74356b41
Source: StackOverflow