Share via


X509CertificateRecipientClientCredential.SetScopedCertificate Méthode

Définition

Définit un certificat d'un magasin et le stocke dans une collection indexée par l'URL qui définit la portée.

Surcharges

SetScopedCertificate(String, StoreLocation, StoreName, Uri)

Définit un certificat par nom de sujet, emplacement de magasin de certificats et nom de magasin de certificats, et le stocke dans une collection à utiliser pour l'URL qui définit la portée.

SetScopedCertificate(StoreLocation, StoreName, X509FindType, Object, Uri)

Définit un certificat par emplacement de magasin de certificats, nom de magasin de certificats, type de recherche X.509 et valeur à rechercher, et les stocke dans une collection à utiliser pour l'URL qui définit la portée.

SetScopedCertificate(String, StoreLocation, StoreName, Uri)

Source:
X509CertificateRecipientClientCredential.cs
Source:
X509CertificateRecipientClientCredential.cs
Source:
X509CertificateRecipientClientCredential.cs

Définit un certificat par nom de sujet, emplacement de magasin de certificats et nom de magasin de certificats, et le stocke dans une collection à utiliser pour l'URL qui définit la portée.

public:
 void SetScopedCertificate(System::String ^ subjectName, System::Security::Cryptography::X509Certificates::StoreLocation storeLocation, System::Security::Cryptography::X509Certificates::StoreName storeName, Uri ^ targetService);
public void SetScopedCertificate (string subjectName, System.Security.Cryptography.X509Certificates.StoreLocation storeLocation, System.Security.Cryptography.X509Certificates.StoreName storeName, Uri targetService);
member this.SetScopedCertificate : string * System.Security.Cryptography.X509Certificates.StoreLocation * System.Security.Cryptography.X509Certificates.StoreName * Uri -> unit
Public Sub SetScopedCertificate (subjectName As String, storeLocation As StoreLocation, storeName As StoreName, targetService As Uri)

Paramètres

subjectName
String

Le nom de sujet complet.

storeLocation
StoreLocation

L'emplacement du magasin de certificats que le service utilise pour obtenir le certificat de service.

storeName
StoreName

Le nom du magasin de certificats X.509 à ouvrir.

targetService
Uri

L'URL qui définit la portée.

Exceptions

subjectName ou targetService est null.

A tenté de définir quand les informations d'identification sont en lecture seule.

Exemples

Ce code montre comment appeler cette méthode.

public void snippet25(CalculatorClient cc)
{
    X509CertificateRecipientClientCredential rcc = cc.ClientCredentials.ServiceCertificate;
    rcc.SetScopedCertificate("http://fabrikam.com/sts",
                             StoreLocation.CurrentUser,
                             StoreName.TrustedPeople,
                             new Uri("http://fabrikam.com"));
}

Remarques

Les valeurs pour storeLocation sont incluses dans l'énumération StoreLocation :

  • LocalMachine: magasin de certificats attribué à l’ordinateur local.

  • CurrentUser: magasin de certificats utilisé par l’utilisateur actuel (par défaut).

Si l'application s'exécute sous un compte système, le certificat se trouve généralement dans LocalMachine. Si l'application s'exécute sous un compte d'utilisateur, le certificat se trouve généralement dans CurrentUser.

Les valeurs pour storeName sont incluses dans l'énumération StoreName.

S’applique à

SetScopedCertificate(StoreLocation, StoreName, X509FindType, Object, Uri)

Source:
X509CertificateRecipientClientCredential.cs
Source:
X509CertificateRecipientClientCredential.cs
Source:
X509CertificateRecipientClientCredential.cs

Définit un certificat par emplacement de magasin de certificats, nom de magasin de certificats, type de recherche X.509 et valeur à rechercher, et les stocke dans une collection à utiliser pour l'URL qui définit la portée.

public:
 void SetScopedCertificate(System::Security::Cryptography::X509Certificates::StoreLocation storeLocation, System::Security::Cryptography::X509Certificates::StoreName storeName, System::Security::Cryptography::X509Certificates::X509FindType findType, System::Object ^ findValue, Uri ^ targetService);
public void SetScopedCertificate (System.Security.Cryptography.X509Certificates.StoreLocation storeLocation, System.Security.Cryptography.X509Certificates.StoreName storeName, System.Security.Cryptography.X509Certificates.X509FindType findType, object findValue, Uri targetService);
member this.SetScopedCertificate : System.Security.Cryptography.X509Certificates.StoreLocation * System.Security.Cryptography.X509Certificates.StoreName * System.Security.Cryptography.X509Certificates.X509FindType * obj * Uri -> unit
Public Sub SetScopedCertificate (storeLocation As StoreLocation, storeName As StoreName, findType As X509FindType, findValue As Object, targetService As Uri)

Paramètres

storeLocation
StoreLocation

L'emplacement du magasin de certificats que le service utilise pour obtenir le certificat de service.

storeName
StoreName

Le nom du magasin de certificats X.509 à ouvrir.

findType
X509FindType

Le type de recherche X.509 à exécuter.

findValue
Object

Valeur à rechercher dans le magasin de certificats X.509.

targetService
Uri

L'URL qui définit la portée.

Exceptions

findValue ou targetService est null.

A tenté de définir quand les informations d'identification sont en lecture seule.

Exemples

Ce code montre comment appeler cette méthode.

public void snippet20(CalculatorClient client)
{
    X509CertificateRecipientClientCredential rcc = client.ClientCredentials.ServiceCertificate;
    rcc.SetScopedCertificate(StoreLocation.CurrentUser,
                             StoreName.TrustedPeople,
                             X509FindType.FindBySubjectName,
                             "FabrikamSTS",
                             new Uri("http://fabrikam.com/sts"));
}
rcc.SetScopedCertificate(StoreLocation.CurrentUser, _
            StoreName.TrustedPeople, _
            X509FindType.FindBySubjectName, _
            "FabrikamSTS", _
            New Uri("http://fabrikam.com/sts"))

Remarques

Les valeurs pour storeLocation sont incluses dans l'énumération StoreLocation :

  • LocalMachine: magasin de certificats attribué à l’ordinateur local.

  • CurrentUser: magasin de certificats utilisé par l’utilisateur actuel (par défaut).

Si l'application s'exécute sous un compte système, le certificat se trouve généralement dans LocalMachine. Si l'application s'exécute sous un compte d'utilisateur, le certificat se trouve généralement dans CurrentUser.

Les valeurs pour storeName sont incluses dans l'énumération StoreName.

Les valeurs pour findType sont incluses dans l'énumération X509FindType.

L'énumération la plus communément utilisée est FindBySubjectName, qui recherche dans le magasin spécifié (non sensible à la casse) le nom de sujet des certificats. Cette recherche peut être imprécise. Si aucun certificat ou plusieurs certificats qui correspondent aux critères sont trouvés, InvalidOperationException est levé.

S’applique à