EndpointIdentity.CreateX509CertificateIdentity Metod
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Skapar en X509Certificate-identitet.
Överlagringar
| Name | Description |
|---|---|
| CreateX509CertificateIdentity(X509Certificate2) |
Skapar en X509Certificate-identitet med det angivna certifikatet. |
| CreateX509CertificateIdentity(X509Certificate2, X509Certificate2Collection) |
Skapar en X509Certificate-identitet med angivna primära och stödjande certifikat. |
Kommentarer
Välj mellan dessa två konstruktorer baserat på om du har stödcertifikat.
En säker WCF-klient som ansluter till en slutpunkt med den här identiteten verifierar att anspråken som presenteras av servern innehåller anspråket som innehåller tumavtrycket för det certifikat som används för att konstruera den här identiteten.
CreateX509CertificateIdentity(X509Certificate2)
Skapar en X509Certificate-identitet med det angivna certifikatet.
public:
static System::ServiceModel::EndpointIdentity ^ CreateX509CertificateIdentity(System::Security::Cryptography::X509Certificates::X509Certificate2 ^ certificate);
public static System.ServiceModel.EndpointIdentity CreateX509CertificateIdentity(System.Security.Cryptography.X509Certificates.X509Certificate2 certificate);
static member CreateX509CertificateIdentity : System.Security.Cryptography.X509Certificates.X509Certificate2 -> System.ServiceModel.EndpointIdentity
Public Shared Function CreateX509CertificateIdentity (certificate As X509Certificate2) As EndpointIdentity
Parametrar
- certificate
- X509Certificate2
En X509Certificate2 som innehåller certifikatet för identiteten.
Returer
En X509Certificate EndpointIdentity som är associerad med den angivna certificate.
Undantag
certificate är null.
Exempel
Följande kod visar hur du anropar den här metoden.
// This method creates a WSFederationHttpBinding.
public static WSFederationHttpBinding CreateWSFederationHttpBinding()
{
// Create an instance of the WSFederationHttpBinding.
WSFederationHttpBinding b = new WSFederationHttpBinding();
// Set the security mode to Message.
b.Security.Mode = WSFederationHttpSecurityMode.Message;
// Set the Algorithm Suite to Basic256Rsa15.
b.Security.Message.AlgorithmSuite = SecurityAlgorithmSuite.Basic256Rsa15;
// Set NegotiateServiceCredential to true.
b.Security.Message.NegotiateServiceCredential = true;
// Set IssuedKeyType to Symmetric.
b.Security.Message.IssuedKeyType = SecurityKeyType.SymmetricKey;
// Set IssuedTokenType to SAML 1.1.
b.Security.Message.IssuedTokenType = "http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#samlv1.1";
// Extract the STS certificate from the certificate store.
X509Store store = new X509Store(StoreName.TrustedPeople, StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadOnly);
X509Certificate2Collection certs = store.Certificates.Find(X509FindType.FindByThumbprint, "cd 54 88 85 0d 63 db ac 92 59 05 af ce b8 b1 de c3 67 9e 3f", false);
store.Close();
// Create an EndpointIdentity from the STS certificate.
EndpointIdentity identity = EndpointIdentity.CreateX509CertificateIdentity(certs[0]);
// Set the IssuerAddress using the address of the STS and the previously created EndpointIdentity.
b.Security.Message.IssuerAddress = new EndpointAddress(new Uri("http://localhost:8000/sts/x509"), identity);
// Set the IssuerBinding to a WSHttpBinding loaded from config
b.Security.Message.IssuerBinding = new WSHttpBinding("Issuer");
// Set the IssuerMetadataAddress using the metadata address of the STS and the previously created EndpointIdentity.
b.Security.Message.IssuerMetadataAddress = new EndpointAddress(new Uri("http://localhost:8001/sts/mex"), identity);
// Create a ClaimTypeRequirement.
ClaimTypeRequirement ctr = new ClaimTypeRequirement("http://example.org/claim/c1", false);
// Add the ClaimTypeRequirement to ClaimTypeRequirements.
b.Security.Message.ClaimTypeRequirements.Add(ctr);
// Return the created binding.
return b;
}
}
Kommentarer
En säker WCF-klient som ansluter till en slutpunkt med den här identiteten verifierar att anspråken som presenteras av servern innehåller anspråket som innehåller tumavtrycket för det certifikat som används för att konstruera den här identiteten.
Den här static metoden skapar en instans av X509CertificateEndpointIdentity genom att anropa konstruktorn, X509CertificateEndpointIdentity, med som certificate indataparameter.
Gäller för
CreateX509CertificateIdentity(X509Certificate2, X509Certificate2Collection)
Skapar en X509Certificate-identitet med angivna primära och stödjande certifikat.
public:
static System::ServiceModel::EndpointIdentity ^ CreateX509CertificateIdentity(System::Security::Cryptography::X509Certificates::X509Certificate2 ^ primaryCertificate, System::Security::Cryptography::X509Certificates::X509Certificate2Collection ^ supportingCertificates);
public static System.ServiceModel.EndpointIdentity CreateX509CertificateIdentity(System.Security.Cryptography.X509Certificates.X509Certificate2 primaryCertificate, System.Security.Cryptography.X509Certificates.X509Certificate2Collection supportingCertificates);
static member CreateX509CertificateIdentity : System.Security.Cryptography.X509Certificates.X509Certificate2 * System.Security.Cryptography.X509Certificates.X509Certificate2Collection -> System.ServiceModel.EndpointIdentity
Public Shared Function CreateX509CertificateIdentity (primaryCertificate As X509Certificate2, supportingCertificates As X509Certificate2Collection) As EndpointIdentity
Parametrar
- primaryCertificate
- X509Certificate2
En X509Certificate2 som innehåller det primära certifikatet för identiteten.
- supportingCertificates
- X509Certificate2Collection
En X509Certificate2Collection som innehåller stödcertifikaten för identiteten.
Returer
En säker WCF-klient som ansluter till en slutpunkt med den här identiteten verifierar att anspråken som presenteras av servern innehåller anspråket som innehåller tumavtrycket för det certifikat som används för att konstruera den här identiteten.
En X509Certificate EndpointIdentity som är associerad med angiven primaryCertificate och supportingCertificates.
Undantag
primaryCertificate eller supportingCertificates är null.
Kommentarer
Den här statiska metoden skapar en instans av X509CertificateEndpointIdentity genom att anropa konstruktorn, , X509CertificateEndpointIdentitymed och primaryCertificatesupportingCertificates som indataparametrar.