【问题标题】:Service Bus The token has an invalid signature服务总线 令牌的签名无效
【发布时间】:2015-11-11 14:16:04
【问题描述】:

我正在尝试创建基于this article 的服务总线中继

我收到一条错误消息 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();
    }

错误信息出现在sh.Open();

谁能帮忙?

【问题讨论】:

    标签: c# azure servicebus


    【解决方案1】:

    我也收到了这个错误信息,结果和张安迪是一样的问题。

    我删除了服务总线以测试自动化部署,并且仍然在连接字符串中引用旧的 SharedAccessKey 进行连接,但在重新部署后这种情况发生了变化。

    我们将连接字符串存储在 Key Vault 中,因此我不得不更改其中的连接字符串来解决问题。

    【讨论】:

      【解决方案2】:

      我遇到了和你第一次一样的错误。

      但我的问题是我使用连接字符串作为键。然后我把key的最后一个参数SharedAccessKey改了,错误已经解决了。

      【讨论】:

      • 你能解释一下你改变了什么吗?
      【解决方案3】:

      特别是对我而言在我的本地环境中,我在 Visual Studio 打开时对环境变量进行了更改——其中一个是服务总线连接字符串。

      Visual Studio 将在启动时缓存环境变量。

      关闭 Visual Studio,重新打开并再次运行解决了我的问题。

      【讨论】:

        【解决方案4】:

        看来我已经解决了问题,键中的正斜杠没有转义

        下一个问题是我现在得到以下但想先排除我们的防火墙

        <Error>
          <Code>400</Code>
            <Detail>
              Cannot send message because the service endpoint hosted at the specified address uses a binding that cannot be accessed over HTTP. TrackingId:7e6402e1-a250-482b-967e-a4d1860bca54_G37,TimeStamp:11/12/2015 9:09:15 AM
            </Detail>
        </Error>
        

        【讨论】:

          猜你喜欢
          • 2019-04-23
          • 2021-06-21
          • 2017-05-30
          • 2017-10-15
          • 2018-07-22
          • 2017-10-16
          • 1970-01-01
          • 2011-10-25
          • 2018-03-16
          相关资源
          最近更新 更多