X509CertificateRecipientServiceCredential.Certificate 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置在向客户端反馈时用于表示服务的证书。
public:
property System::Security::Cryptography::X509Certificates::X509Certificate2 ^ Certificate { System::Security::Cryptography::X509Certificates::X509Certificate2 ^ get(); void set(System::Security::Cryptography::X509Certificates::X509Certificate2 ^ value); };
public System.Security.Cryptography.X509Certificates.X509Certificate2 Certificate { get; set; }
member this.Certificate : System.Security.Cryptography.X509Certificates.X509Certificate2 with get, set
Public Property Certificate As X509Certificate2
属性值
向客户端反馈时用于表示服务的 X509Certificate2。
例外
试图在凭据为只读时进行设置。
示例
下面的代码演示如何使用此方法获取服务凭据中使用的证书。
NetTcpBinding b = new NetTcpBinding();
b.Security.Mode = SecurityMode.Message;
Type c = typeof(ICalculator);
Uri a = new Uri("net.tcp://MyMachineName/tcpBase");
Uri[] baseAddresses = new Uri[] { a };
ServiceHost sh = new ServiceHost(typeof(MyService), baseAddresses);
sh.AddServiceEndpoint(c, b, "Aloha");
sh.Credentials.ServiceCertificate.SetCertificate(
StoreLocation.LocalMachine,
StoreName.My,
X509FindType.FindByThumbprint,
"af1f50b20cd413ed9cd00c315bbb6dc1c08da5e6");
sh.Open();
X509Certificate2 cert = sh.Credentials.ServiceCertificate.Certificate;
Dim b As New NetTcpBinding()
b.Security.Mode = SecurityMode.Message
Dim c As Type = GetType(ICalculator)
Dim a As New Uri("net.tcp://MyMachineName/tcpBase")
Dim baseAddresses() As Uri = { a }
Dim sh As New ServiceHost(GetType(MyService), baseAddresses)
sh.AddServiceEndpoint(c, b, "Aloha")
sh.Credentials.ServiceCertificate.SetCertificate(StoreLocation.LocalMachine, StoreName.My, X509FindType.FindByThumbprint, "af1f50b20cd413ed9cd00c315bbb6dc1c08da5e6")
sh.Open()
Dim cert As X509Certificate2 = sh.Credentials.ServiceCertificate.Certificate
注解
此属性用于获取或设置用于表示服务的证书。