ServiceCredentials.ServiceCertificate Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
Property Value
An X509CertificateRecipientServiceCredential instance.
Examples
This code shows how to specify the certificate that a service uses.
A ServiceHost class is created, followed by a single complex code statement that does the following:
Credentials property is used to access an instance of ServiceCredentials.
The ServiceCredentials instance then invokes ServiceCertificate.
The ServiceCertificate property returns a X509CertificateRecipientServiceCredential object, on which the SetCertificate method is then called.
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();
Remarks
You can specify the certificate to use by calling members of the X509CertificateRecipientServiceCredential object returned by this property.
You can also set this value using the <certificate> element in a client application configuration file.
Applies to
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기