【问题标题】:Cannot connect to Secure Service Fabric cluster from C#无法从 C# 连接到 Secure Service Fabric 群集
【发布时间】:2018-07-19 23:26:02
【问题描述】:

我已经部署了一个安全的 Service Fabric 集群,并且能够使用证书通过浏览器和 Powershell 进行连接。当从 C# 中尝试相同的错误时:

执行过程中发生错误

在 System.Fabric.Interop.Utility.WrapNativeSyncInvoke[TResult](Func`1 func, 字符串 functionTag, 字符串 functionArgs) 在 System.Fabric.Interop.Utility.RunInMTA(动作动作)在 System.Fabric.FabricClient.InitializeFabricClient(SecurityCredentials credentialArg,FabricClientSettings 新设置,字符串 [] hostEndpointsArg) 在 CloseAppAPI.Controllers.CloseClientController.d__0.MoveNext() 在 C:\Users\kumar.kshitij\source\repos\CloseAPP\CloseAppAPI\Controllers\CloseClientController.cs:line 39 英寸。

附上图片和代码供参考。如果您有解决方案,请任何人告诉我。

C#代码如下:-

        string CommonName = "www.cluster1.eastus2.cloudapp.azure.com";
        string connection = "cluster1.eastus2.cloudapp.azure.com:19000";

        var xc = GetCredentials(CommonName);

            var fc = new FabricClient(xc, connection);

             static X509Credentials GetCredentials(string clientCertThumb, 
              string serverCertThumb, string name)
          {
        X509Credentials xc = new X509Credentials();
        xc.StoreLocation = StoreLocation.LocalMachine;
        xc.StoreName = "Personal";
        xc.FindType = X509FindType.FindByThumbprint;
        xc.FindValue = "08DF81BD17507D4ADEC4DEE075E33A3CB8C8D04E";

        xc.RemoteCommonNames.Add(name);        

   xc.RemoteCertThumbprints.Add("3D317C232F06AC1F5A2C8D16CC2830D6F7CD5FAC");
        //xc.ProtectionLevel = ProtectionLevel.EncryptAndSign;
        return xc;
    }

【问题讨论】:

    标签: c# powershell azure-service-fabric


    【解决方案1】:

    您在 PowerShell 中为 StoreLocation 和 StoreName 使用了不同的值。

    尝试替换

    xc.StoreName = "Personal"; xc.StoreLocation = StoreLocation.LocalMachine;

    xc.StoreLocation = StoreLocation.CurrentUser; xc.StoreName = "TrustedPeople";

    【讨论】:

    • 我尝试更改存储位置和名称,但再次出现相同的错误 :( 是不是 Visual Studio 无法找到该特定证书
    • 检查您的代码中的缩略图是否在其末尾有一个未打印的字符,如果您是从 MMC 复制的。 support.microsoft.com/en-us/help/2023835/…
    • 我也刚刚检查过..仍然无法正常工作...我可以分享我的屏幕吗?如果您可以指导我...
    猜你喜欢
    • 2020-01-12
    • 2018-07-03
    • 2018-09-09
    • 2017-11-11
    • 2016-12-06
    • 2018-11-09
    • 1970-01-01
    • 2016-09-28
    • 2018-12-11
    相关资源
    最近更新 更多