azure - 无法对安全 Service Fabric 群集的 FabricClient 进行身份验证

标签 azure authentication azure-service-fabric

我有一个安全的服务结构集群。相同的证书用作服务器证书和客户端身份验证。我无法在控制台应用程序中创建允许我连接到此集群的 FabricClient。我正在使用“使用客户端证书连接到安全集群”下记录的 here 代码片段:

static void Main(string[] args)
{
    string thumb = "‎1234567890123456789012345678901234567890";
    string CommonName = "somefabric.cloudapp.azure.com";
    string connection = "somefabric.cloudapp.azure.com:19000";

    try
    {
        X509Credentials xc = GetCredentials(thumb, thumb, CommonName);
        FabricClient fc = new FabricClient(xc, connection);
        Console.WriteLine("Cluster is connected");
    }
    catch (Exception e)
    {
        Console.WriteLine(e.Message);
    }
    Console.ReadKey();
}


static X509Credentials GetCredentials(string clientCertThumb, string serverCertThumb, string name)
{
    X509Credentials xc = new X509Credentials();

    // Client certificate
    xc.StoreLocation = StoreLocation.CurrentUser;
    xc.StoreName = "MY";
    xc.FindType = X509FindType.FindByThumbprint;
    xc.FindValue = clientCertThumb;

    // Server certificate
    xc.RemoteCertThumbprints.Add(serverCertThumb);
    xc.RemoteCommonNames.Add(name);

    xc.ProtectionLevel = ProtectionLevel.EncryptAndSign;
    return xc;
}

这段代码的结果是

The X509 thumbprint specified is invalid.

证书似乎确实通过其他方式授予我访问权限。我能够成功查看 Fabric Explorer 并 以下 PowerShell 命令也成功连接到集群

Connect-ServiceFabricCluster 
    -ConnectionEndpoint somefabric.cloudapp.azure.com:19000 
    -X509Credential 
    -FindType FindByThumbprint 
    -FindValue 1234567890123456789012345678901234567890 
    -StoreLocation CurrentUser 
    -StoreName MY 
    -ServerCertThumbprint 1234567890123456789012345678901234567890

我在这里做错了什么?

最佳答案

我遇到了这个确切的问题,但原因却截然不同。

我对此感到困惑;

  • https Explorer 可以工作(在 IExporer 中)
  • Powershell Connect-ServiceFabricCluster 也有效。
  • Visual Studio 发布失败

我发现我的指纹值附加了 4 个不可见字符,这可能是剪切和粘贴操作造成的。怎么,为什么?不知道

只有在编辑 Deploy-FabricApplication 添加此行后我才发现这一点。

$publishProfile.ClusterConnectionParameters|Format-List

就在

之前
[void](Connect-ServiceFabricCluster @ClusterConnectionParameters)

然后我看到不可见的字符显示为 ????在指纹的末尾。

使用二进制编辑器打开 Cloud.xml 文件可以让我查看它们并删除它们。

然后我就可以发布我的应用程序。

关于azure - 无法对安全 Service Fabric 群集的 FabricClient 进行身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41043912/

相关文章:

azure - 如何使用 Key 以外的其他方式查找有状态服务的数据

linux - 无法导入容器镜像错误 fabric_e_invalid_operation

azure-service-fabric - 用于管理集群的 TCP 端口

azure - Cosmos Db 每个数据库、每个帐户或每个订阅的集合是否有任何限制(多少)?

azure - 网络+ worker 角色成本

python - 无法设置 Azure Data Lake 文件的内容类型

node.js - 使用什么身份验证策略?

c# - 将视频 (mp4) 上传到 Azure Blob 存储

authentication - 企业代理背后的 asp.net core 3.1 azure ad SSO 身份验证

Swift HTTP POST 登录验证