【发布时间】:2019-10-02 23:53:38
【问题描述】:
我有一个安全的 Service Fabric 集群。相同的证书被用作服务器证书和客户端身份验证。我无法在控制台应用程序中创建FabricClient 以允许我连接到此集群。我正在使用“使用客户端证书连接到安全集群”下记录的代码 sn-p 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;
}
这段代码导致
指定的 X509 指纹无效。
证书似乎确实通过其他方式授予我访问权限。我能够成功查看 Fabric Explorer 和 以下 PowerShell 命令也成功连接到集群
Connect-ServiceFabricCluster
-ConnectionEndpoint somefabric.cloudapp.azure.com:19000
-X509Credential
-FindType FindByThumbprint
-FindValue 1234567890123456789012345678901234567890
-StoreLocation CurrentUser
-StoreName MY
-ServerCertThumbprint 1234567890123456789012345678901234567890
我在这里做错了什么?
【问题讨论】:
标签: azure authentication azure-service-fabric