Export (0) Print
Expand All

X509CertificateRecipientServiceCredential.SetCertificate Method (String)

Specifies the certificate to use for representing the service by specifying the subject distinguished name.

Namespace:  System.ServiceModel.Security
Assembly:  System.ServiceModel (in System.ServiceModel.dll)

public void SetCertificate(
	string subjectName
)

Parameters

subjectName
Type: System.String
Subject distinguished name.

For more information on the subjectName parameter, see SubjectName.

The following code shows how to use this method to set a certificate for a service credential from a subject name.


            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(
                "CN=Administrator,CN=Users,DC=johndoe,DC=nttest,DC=microsoft,DC=com");
            sh.Open();



.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

ADD
Show:
© 2014 Microsoft