Compartir a través de


X509CertificateRecipientServiceCredential.Certificate Propiedad

Definición

Obtiene o establece el certificado que se va a utilizar para representar al servicio que vuelve a comunicarse con el cliente.

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

Valor de propiedad

X509Certificate2

X509Certificate2 que se utiliza para representar al servicio que vuelve a comunicarse con el cliente.

Excepciones

Se intentó establecer cuando la credencial es de solo lectura.

Ejemplos

El siguiente código muestra cómo utilizar este método para obtener el certificado utilizado en las credenciales de un servicio.

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

Comentarios

Esta propiedad se utiliza para obtener o establecer el certificado utilizado para representar el servicio.

Se aplica a