ServiceCredentials.ServiceCertificate Propriedade

Definição

Obtém o certificado atual associado a esse serviço.Gets the current certificate associated with this service.

public:
 property System::ServiceModel::Security::X509CertificateRecipientServiceCredential ^ ServiceCertificate { System::ServiceModel::Security::X509CertificateRecipientServiceCredential ^ get(); };
public System.ServiceModel.Security.X509CertificateRecipientServiceCredential ServiceCertificate { get; }
member this.ServiceCertificate : System.ServiceModel.Security.X509CertificateRecipientServiceCredential
Public ReadOnly Property ServiceCertificate As X509CertificateRecipientServiceCredential

Valor da propriedade

X509CertificateRecipientServiceCredential

Uma instância X509CertificateRecipientServiceCredential.An X509CertificateRecipientServiceCredential instance.

Exemplos

Este código mostra como especificar o certificado que um serviço usa.This code shows how to specify the certificate that a service uses.

Uma ServiceHost classe é criada, seguida por uma única instrução de código complexo que faz o seguinte:A ServiceHost class is created, followed by a single complex code statement that does the following:

Uri a = new Uri("net.tcp://MyMachineName/tcpBase");
Uri[] baseAddresses = new Uri[] { a };
ServiceHost sh = new ServiceHost(typeof(SayHello), baseAddresses);
sh.AddServiceEndpoint(c, b, "Aloha");
sh.Credentials.ServiceCertificate.SetCertificate(
    StoreLocation.LocalMachine,
    StoreName.My,
    X509FindType.FindByThumbprint,
    "af1f50b20cd413ed9cd00c315bbb6dc1c08da5e6");
sh.Open();

Comentários

Você pode especificar o certificado a ser usado chamando membros do X509CertificateRecipientServiceCredential objeto retornado por essa propriedade.You can specify the certificate to use by calling members of the X509CertificateRecipientServiceCredential object returned by this property.

Você também pode definir esse valor usando o elemento < Certificate > em um arquivo de configuração de aplicativo cliente.You can also set this value using the <certificate> element in a client application configuration file.

Aplica-se a