Partager via


EndpointIdentity.CreateRsaIdentity Méthode

Définition

Crée une identité RSA.

Surcharges

CreateRsaIdentity(X509Certificate2)

Crée une identité RSA avec le certificat X.509 spécifié.

CreateRsaIdentity(String)

Crée une identité RSA avec la clé publique spécifiée.

Remarques

Un client WCF sécurisé qui se connecte à un point de terminaison avec cette identité vérifie que les revendications présentées par le serveur contiennent une revendication intégrant la clé publique RSA utilisée pour construire cette identité.

L'une de ces méthodes statiques crée une instance de RsaEndpointIdentity en appelant son constructeur RsaEndpointIdentity.

CreateRsaIdentity(X509Certificate2)

Crée une identité RSA avec le certificat X.509 spécifié.

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

Paramètres

certificate
X509Certificate2

X509Certificate2 contenant le certificat pour l'identité RSA.

Retours

EndpointIdentity

EndpointIdentity RSA associée au certificate spécifié.

Exceptions

certificate a la valeur null.

certificate n'est pas un certificat RSA.

Exemples

L'exemple de code suivant montre comment appeler cette méthode.

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;

Remarques

Un client WCF sécurisé qui se connecte à un point de terminaison avec cette identité vérifie que les revendications présentées par le serveur contiennent une revendication qui contient la clé publique RSA obtenue à partir du certificat utilisé pour construire cette identité.

Cette méthode statique crée une instance de RsaEndpointIdentity en appelant son constructeur RsaEndpointIdentity.

S’applique à

CreateRsaIdentity(String)

Crée une identité RSA avec la clé publique spécifiée.

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

Paramètres

publicKey
String

Clé publique de l'identité RSA.

Retours

EndpointIdentity

EndpointIdentity RSA associée au publicKey spécifié.

Exceptions

publicKey a la valeur null.

Remarques

Un client WCF sécurisé qui se connecte à un point de terminaison avec cette identité vérifie que les revendications présentées par le serveur contiennent une revendication intégrant la clé publique RSA utilisée pour construire cette identité.

Cette méthode statique crée une instance de RsaEndpointIdentity en appelant son constructeur RsaEndpointIdentity.

S’applique à