系统相关
首页 > 系统相关> > c# – Windows Server证书服务总线无法验证

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

作者:互联网

使用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.

我想从我的开发盒连接另一台计算机上的服务总线

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

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!!!

我从Service Bus服务器导出了证书
   使用:Get-SBAutoGeneratedCA
    AutoGeneratedCA.cer
    AutoGeneratedCA.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
建议撤销服务器有问题,因为我也导入了证书Revocatin列表我没有看到这是我的问题

我还发现了this
哪个链接到这个博客post
我没有成功地遵循这个建议.

这个博客Post
建议安装revocationMode =“NoCheck”对此问题没有影响,他的解决方案是欺骗证书撤销列表

这个博客Post
建议添加了端点行为以禁用certificateValidationMode,我做了,我仍然得到错误.

注意:当我在Dev Machine上托管服务总线时,一切正常.

有没有我没试过的建议?

解决方法:

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

我按照这些说明操作了一切……

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

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

标签:c,x509certificate,servicebus
来源: https://codeday.me/bug/20190625/1287792.html