HttpWebRequest.ClientCertificates 属性

定义

获取或设置与此请求关联的安全证书的集合。

public:
 property System::Security::Cryptography::X509Certificates::X509CertificateCollection ^ ClientCertificates { System::Security::Cryptography::X509Certificates::X509CertificateCollection ^ get(); void set(System::Security::Cryptography::X509Certificates::X509CertificateCollection ^ value); };
public:
 property System::Security::Cryptography::X509Certificates::X509CertificateCollection ^ ClientCertificates { System::Security::Cryptography::X509Certificates::X509CertificateCollection ^ get(); };
public System.Security.Cryptography.X509Certificates.X509CertificateCollection ClientCertificates { get; set; }
public System.Security.Cryptography.X509Certificates.X509CertificateCollection ClientCertificates { get; }
member this.ClientCertificates : System.Security.Cryptography.X509Certificates.X509CertificateCollection with get, set
member this.ClientCertificates : System.Security.Cryptography.X509Certificates.X509CertificateCollection
Public Property ClientCertificates As X509CertificateCollection
Public ReadOnly Property ClientCertificates As X509CertificateCollection

属性值

包含与此请求关联的安全证书的 X509CertificateCollection

例外

为集操作指定的值 null

注解

谨慎

WebRequestHttpWebRequestServicePointWebClient 已过时,不应将其用于新开发。 请改用 HttpClient

应用程序可以将证书添加到集合,但可能无权访问它。 若要使用集合中包含的证书,应用程序必须具有与颁发证书的实体相同的访问权限。

注意

框架在创建 SSL 会话时缓存 SSL 会话,并尝试尽可能为新请求重复使用缓存会话。 尝试重用 SSL 会话时,框架使用 ClientCertificates 的第一个元素(如果有),或者尝试重复使用匿名会话(如果 ClientCertificates 为空)。

注意

出于性能原因,不应将客户端证书添加到 HttpWebRequest,除非你知道服务器会要求它。

有关演示如何枚举客户端证书存储中的证书的代码示例,请参阅 X509Certificate2Collection 类。

适用于