c# - 无法验证 Windows Server 证书的服务总线

标签 c# x509certificate servicebus

<分区>

使用 Service Bus for Windows Server

我得到以下异常。

Message=The X.509 certificate CN=*********** is not in the trusted people store. The X.509 certificate CN=******** chain building failed. The certificate that was used has a trust chain that cannot be verified. Replace the certificate or change the certificateValidationMode. The signature of the certificate cannot be verified.

我正在尝试从我的 Dev Box 连接到另一台计算机上的服务总线

这是我正在使用的控制台应用程序的代码。

ServicePointManager.ServerCertificateValidationCallback = 
   new RemoteCertificateValidationCallback(ValidateServerCertificate);
ServicePointManager.CheckCertificateRevocationList = false;

NamespaceManager namespaceManager = NamespaceManager.Create();
MessagingFactory messagingFactory = MessagingFactory.Create();

if (namespaceManager.QueueExists(QueueName))
{    
    namespaceManager.DeleteQueue(QueueName);    
}
namespaceManager.CreateQueue(QueueName);

string QueueName = "ServiceBusQueueSample";                       
QueueClient myQueueClient = messagingFactory.CreateQueueClient(QueueName);

BrokeredMessage sendMessage = new BrokeredMessage("Hello World !");   
myQueueClient.Send(sendMessage); <---- !!!Exception!!!

我从服务总线服务器导出了证书 使用:获取 SBAutoGeneratedCA 自动生成的CA.cer 自动生成的CA.cr1

然后我使用默认设置将这两个文件导入到我的开发箱中。

我已将以下项目添加到我的 app.config 中。

  <system.serviceModel>
    <behaviors>
      <endpointBehaviors>
        <behavior >
          <clientCredentials>
            <serviceCertificate>
              <authentication  certificateValidationMode="None" 
                                                       revocationMode="NoCheck" />
            </serviceCertificate>
          </clientCredentials>
        </behavior>
      </endpointBehaviors>
    </behaviors>
  </system.serviceModel>

  <microsoft.identityModel>    
   <service>       
      <certificateValidation certificateValidationMode="None"    />
   </service>    
  </microsoft.identityModel>

我能够成功验证并检查队列是否存在并将其删除然后创建一个新队列。

在寻找解决方案时,我找到了 this 建议吊销服务器有问题,因为我还导入了证书吊销列表我没有看到这是我的问题

我还找到了this : 哪个链接到这个博客post : 我听从了这个建议,但没有成功。

此博客 Post :
建议设置revocationMode="NoCheck"对此问题没有影响,他的解决方案是欺骗证书吊销列表

此博客 Post : 建议添加端点行为以禁用 certificateValidationMode,我做了但仍然收到错误。

注意:当我在我的开发机器上托管服务总线时,一切正常。

有什么我没有尝试过的建议吗?

最佳答案

事实证明我没有正确导入证书...

我按照这些说明进行操作,一切正常..

http://msdn.microsoft.com/en-us/library/windowsazure/jj192993(v=azure.10).aspx

我想右键单击并安装证书将它们放在了错误的位置。

关于c# - 无法验证 Windows Server 证书的服务总线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13053641/

相关文章:

c# - 如何在布局页面上放置图像?

c# - 如何检索 X509Store 中的所有证书

android - 了解用于从 Android 使用 .Net Web 服务的 SSL

azure - 使用 QPID JMS (AMQP 1.0) 在 Azure ServiceBus 上创建订阅

c# - 如何获取 UTF-16 字节数组?

c# - 如何使用 Linq(聚合)折叠列表?

c# - 使用 System.Speech.Recognition 打开 Windows 语音识别

c# - 以编程方式,需要执行哪些操作才能在 SAP 调用中使用 X.509 客户端证书?

powershell - 在Windows Docker容器中运行ServiceBus

azure - Microsoft Service Bus 是否会为主题中的每个订阅重复消息?