Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Service Bus The token has an invalid signature

I am trying to create a service bus relay based on this article

I get an error message Generic: InvalidSignature: The token has an invalid signature.

static void Main(string[] args)
{
        ServiceHost sh = new ServiceHost(typeof(ProblemSolver));

        sh.AddServiceEndpoint(
           typeof(IProblemSolver), new NetTcpBinding(),
           "net.tcp://tjservicebus.servicebus.windows.net/solver");

        Console.WriteLine("Add Binding End Point");

        var key = "MYKEY";

        sh.AddServiceEndpoint(
           typeof(IProblemSolver), new NetTcpRelayBinding(),
           ServiceBusEnvironment.CreateServiceUri("sb", "tjservicebus", "solver"))
            .Behaviors.Add(new TransportClientEndpointBehavior
            {
                TokenProvider = TokenProvider.CreateSharedAccessSignatureTokenProvider("RootManageSharedAccessKey", key)
            });

        sh.Open();

        Console.WriteLine("Press ENTER to close");
        Console.ReadLine();

        sh.Close();
    }

The error message appears at the point of sh.Open();

Can anyone help?

like image 915
Frazer Avatar asked Nov 11 '15 14:11

Frazer


2 Answers

I also had this error message and it turned out to be the same issue as Andy Zhang.

I deleted the service bus to test automated deployment and was still referencing the old SharedAccessKey in the connection string to connect but this had changed after redeployment.

We stored our connection string in Key Vault, so I had to change the connection string in there to resolve the issue.

like image 70
Dave C Avatar answered Nov 01 '22 10:11

Dave C


I encountered the same error as your first.

But my problem is I used the connection string as the key. Then I have changed the last parameter SharedAccessKey for the key, and the error has been resolved.

like image 31
Andy Zhang Avatar answered Nov 01 '22 11:11

Andy Zhang