我有一个安全的服务结构集群。相同的证书用作服务器证书和客户端身份验证。我无法在控制台应用程序中创建允许我连接到此集群的 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/