【发布时间】:2018-10-17 04:55:11
【问题描述】:
我有一个 C# RestFull 客户端尝试连接到 Go 服务器。一旦我到达 TLS 握手阶段,它就会失败,因为 客户端没有提供证书。
在执行请求之前,我已验证客户端证书与 RestClient 对象相关联。
// Initializing the client
RestClient client = new RestClient(Config.SERVER_DOMAIN);
// Adding client certificate (exported from a smart card with no private key attributes)
client.ClientCertificates = Global.cpf.getCertCollection();
// defining our request then executing it
var request = new RestRequest("users", Method.GET);
var response = await client.ExecuteTaskAsync(request);
仅当证书是从私有组件所在的 .PFX 文件中读取时才有效。但是当我切换到智能卡证书(它没有私钥属性,因为智能卡不希望你拥有它们)时,服务器没有收到来自客户端的任何证书。
我知道 TLS 在握手阶段需要一个私钥,但客户端 obj 没有看到任何与给定证书关联的私钥,因此无法将该证书识别为 TLS 建立的有效证书。
我知道私钥不能从智能卡中导出,并且我知道必须有一种方法告诉 RestClient 对象,为了通过握手阶段,您应该与智能卡进行通信,但是,我放弃了!
有人能指出正确的方向吗?
【问题讨论】:
-
client.ClientCertificates的类型是什么? -
X509Certificate2 的集合(在我的例子中只有一个),没有私钥。
标签: c# authentication ssl smartcard pkcs#11