X509SelectionFlag Перечисление

Определение

Задает тип запрошенного выбора с помощью метода SelectFromCollection.

public enum class X509SelectionFlag
public enum X509SelectionFlag
type X509SelectionFlag = 
Public Enum X509SelectionFlag
Наследование
X509SelectionFlag

Поля

MultiSelection 1

Выбор нескольких сертификатов. Нажмите клавишу SHIFT или CRTL, чтобы выбрать несколько сертификатов X.509.

SingleSelection 0

Выбор одного сертификата. Пользовательский интерфейс позволяет выбирать один сертификат X.509.

Примеры

В следующем примере кода показано, как использовать флаг выбора с методом X509Certificate2UI.SelectFromCollection . Этот пример входит в состав более крупного примера использования класса X509Store. Более крупный пример открывает хранилище личных сертификатов текущего пользователя, позволяет пользователю выбрать сертификат, а затем записывает сведения о сертификате и цепочке сертификатов в консоль. Выходные данные зависят от сертификата, выбранного пользователем.

//Create new X509 store from local certificate store.
X509Store ^ store = gcnew X509Store( "MY",StoreLocation::CurrentUser );
store->Open( static_cast<OpenFlags>(OpenFlags::OpenExistingOnly | OpenFlags::ReadWrite) );

//Output store information.
Console::WriteLine( "Store Information" );
Console::WriteLine( "Number of certificates in the store: {0}", store->Certificates->Count );
Console::WriteLine( "Store location: {0}", store->Location );
Console::WriteLine( "Store name: {0} {1}", store->Name, Environment::NewLine );

//Put certificates from the store into a collection so user can select one.
X509Certificate2Collection ^ fcollection = dynamic_cast<X509Certificate2Collection^>(store->Certificates);
X509Certificate2Collection ^ collection = X509Certificate2UI::SelectFromCollection(fcollection, "Select an X509 Certificate","Choose a certificate to examine.",X509SelectionFlag::SingleSelection);
X509Certificate2 ^ certificate = collection[ 0 ];
X509Certificate2UI::DisplayCertificate(certificate);
    //Create new X509 store from local certificate store.
    X509Store store = new X509Store("MY", StoreLocation.CurrentUser);
    store.Open(OpenFlags.OpenExistingOnly | OpenFlags.ReadWrite);

    //Output store information.
    Console.WriteLine ("Store Information");
    Console.WriteLine ("Number of certificates in the store: {0}", store.Certificates.Count);
    Console.WriteLine ("Store location: {0}", store.Location);
    Console.WriteLine ("Store name: {0} {1}", store.Name, Environment.NewLine);

    //Put certificates from the store into a collection so user can select one.
    X509Certificate2Collection fcollection = (X509Certificate2Collection)store.Certificates;
    X509Certificate2Collection collection = X509Certificate2UI.SelectFromCollection(fcollection, "Select an X509 Certificate", "Choose a certificate to examine.", X509SelectionFlag.SingleSelection);
    X509Certificate2 certificate = collection[0];
    X509Certificate2UI.DisplayCertificate(certificate);
'Create new X509 store from local certificate store.
Dim store As New X509Store("MY", StoreLocation.CurrentUser)
store.Open(OpenFlags.OpenExistingOnly Or OpenFlags.ReadWrite)

'Output store information.
Console.WriteLine("Store Information")
Console.WriteLine("Number of certificates in the store: {0}", store.Certificates.Count)
Console.WriteLine("Store location: {0}", store.Location)
Console.WriteLine("Store name: {0} {1}", store.Name, Environment.NewLine)

'Put certificates from the store into a collection so user can select one.
Dim fcollection As X509Certificate2Collection = CType(store.Certificates, X509Certificate2Collection)
Dim collection As X509Certificate2Collection = X509Certificate2UI.SelectFromCollection(fcollection, "Select an X509 Certificate", "Choose a certificate to examine.", X509SelectionFlag.SingleSelection)
Dim certificate As X509Certificate2 = collection(0)
X509Certificate2UI.DisplayCertificate(certificate)

Комментарии

Этот флаг представляет один или несколько сертификатов, выбранных с помощью X509Certificate2UI.SelectFromCollection метода .

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