EndpointIdentity.CreateRsaIdentity Метод

Определение

Создает удостоверение RSA.

Перегрузки

CreateRsaIdentity(X509Certificate2)

Создает удостоверение RSA с указанным сертификатом X.509.

CreateRsaIdentity(String)

Создает удостоверение RSA с указанным открытым ключом.

Комментарии

Защищенный клиент WCF, подключающийся к конечной точке с использованием этого удостоверения, проверяет, что среди утверждений, представленных сервером, есть утверждение, содержащее открытый ключ RSA, который используется для конструирования этого удостоверения.

Один из этих статических методов создает экземпляр RsaEndpointIdentity, вызывая его конструктор RsaEndpointIdentity.

CreateRsaIdentity(X509Certificate2)

Создает удостоверение RSA с указанным сертификатом X.509.

public:
 static System::ServiceModel::EndpointIdentity ^ CreateRsaIdentity(System::Security::Cryptography::X509Certificates::X509Certificate2 ^ certificate);
public static System.ServiceModel.EndpointIdentity CreateRsaIdentity (System.Security.Cryptography.X509Certificates.X509Certificate2 certificate);
static member CreateRsaIdentity : System.Security.Cryptography.X509Certificates.X509Certificate2 -> System.ServiceModel.EndpointIdentity
Public Shared Function CreateRsaIdentity (certificate As X509Certificate2) As EndpointIdentity

Параметры

certificate
X509Certificate2

Объект X509Certificate2, содержащий сертификат для удостоверения RSA.

Возвращаемое значение

EndpointIdentity

EndpointIdentity RSA, связанное с заданным параметром certificate.

Исключения

certificate имеет значение null.

certificate не является сертификатом RSA.

Примеры

В следующем примере кода показано, как вызвать этот метод.

public static void CreateRSAIdentity()
{
    // Create a ServiceHost for the CalculatorService type. Base Address is supplied in app.config.
    using (ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService)))
    {
        // The base address is read from the app.config.
        Uri dnsrelativeAddress = new Uri(serviceHost.BaseAddresses[0], "dnsidentity");
        Uri certificaterelativeAddress = new Uri(serviceHost.BaseAddresses[0], "certificateidentity");
        Uri rsarelativeAddress = new Uri(serviceHost.BaseAddresses[0], "rsaidentity");

        // Set the service's X509Certificate to protect the messages.
        serviceHost.Credentials.ServiceCertificate.SetCertificate(StoreLocation.LocalMachine,
                                                                  StoreName.My,
                                                                  X509FindType.FindBySubjectDistinguishedName,
                                                                  "CN=identity.com, O=Contoso");
        //Cache a reference to the server's certificate.
        X509Certificate2 servercert = serviceHost.Credentials.ServiceCertificate.Certificate;

        //Create endpoints for the service using a WSHttpBinding set for anonymous clients.
        WSHttpBinding wsAnonbinding = new WSHttpBinding(SecurityMode.Message);
        //Clients are anonymous to the service.
        wsAnonbinding.Security.Message.ClientCredentialType = MessageCredentialType.None;
        //Secure conversation (session) is turned off.
        wsAnonbinding.Security.Message.EstablishSecurityContext = false;

        //Create a service endpoint and change its identity to the DNS for an X509 Certificate.
        ServiceEndpoint ep = serviceHost.AddServiceEndpoint(typeof(ICalculator),
                                                            wsAnonbinding,
                                                            String.Empty);
        EndpointAddress epa = new EndpointAddress(dnsrelativeAddress, EndpointIdentity.CreateDnsIdentity("identity.com"));
        ep.Address = epa;

        //Create a service endpoint and change its identity to the X509 certificate's RSA key value.
        ServiceEndpoint ep3 = serviceHost.AddServiceEndpoint(typeof(ICalculator), wsAnonbinding, String.Empty);
        EndpointAddress epa3 = new EndpointAddress(rsarelativeAddress, EndpointIdentity.CreateRsaIdentity(servercert));
        ep3.Address = epa3;

Комментарии

Защищенный клиент WCF, который подключается к конечной точке с этим удостоверением, проверяет, содержат ли утверждения, представленные сервером, утверждение, содержащее открытый ключ RSA, полученный из сертификата, используемого для создания этого удостоверения.

Статический метод создает экземпляр RsaEndpointIdentity, вызывая его конструктор RsaEndpointIdentity.

Применяется к

CreateRsaIdentity(String)

Создает удостоверение RSA с указанным открытым ключом.

public:
 static System::ServiceModel::EndpointIdentity ^ CreateRsaIdentity(System::String ^ publicKey);
public static System.ServiceModel.EndpointIdentity CreateRsaIdentity (string publicKey);
static member CreateRsaIdentity : string -> System.ServiceModel.EndpointIdentity
Public Shared Function CreateRsaIdentity (publicKey As String) As EndpointIdentity

Параметры

publicKey
String

Открытый ключ для удостоверения RSA.

Возвращаемое значение

EndpointIdentity

EndpointIdentity RSA, связанное с заданным параметром publicKey.

Исключения

publicKey имеет значение null.

Комментарии

Защищенный клиент WCF, подключающийся к конечной точке с использованием этого удостоверения, проверяет, что среди утверждений, представленных сервером, есть утверждение, содержащее открытый ключ RSA, который используется для конструирования этого удостоверения.

Статический метод создает экземпляр RsaEndpointIdentity, вызывая его конструктор RsaEndpointIdentity.

Применяется к