CngKey.Open Metodo

Definizione

Crea un'istanza di un oggetto CngKey che rappresenta una chiave esistente.

Overload

Open(String)

Crea un'istanza di un oggetto CngKey che rappresenta una chiave denominata esistente.

Open(SafeNCryptKeyHandle, CngKeyHandleOpenOptions)

Crea un'istanza di un oggetto CngKey utilizzando un handle per una chiave esistente.

Open(String, CngProvider)

Crea un'istanza di un oggetto CngKey che rappresenta una chiave denominata esistente, utilizzando il provider di archiviazione chiavi (KSP) specificato.

Open(String, CngProvider, CngKeyOpenOptions)

Crea un'istanza di un oggetto CngKey che rappresenta una chiave denominata esistente, utilizzando il provider di archiviazione chiavi (KSP) e le opzioni di apertura della chiave specificati.

Open(String)

Crea un'istanza di un oggetto CngKey che rappresenta una chiave denominata esistente.

public:
 static System::Security::Cryptography::CngKey ^ Open(System::String ^ keyName);
public static System.Security.Cryptography.CngKey Open (string keyName);
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public static System.Security.Cryptography.CngKey Open (string keyName);
static member Open : string -> System.Security.Cryptography.CngKey
[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]
static member Open : string -> System.Security.Cryptography.CngKey
Public Shared Function Open (keyName As String) As CngKey

Parametri

keyName
String

Nome della chiave.

Restituisce

CngKey

Chiave esistente.

Attributi

Eccezioni

keyName è null.

Cryptography Next Generation non è supportato in questo sistema.

Tutti gli altri errori.

Commenti

Questo overload usa le impostazioni predefinite seguenti:

Si applica a

Open(SafeNCryptKeyHandle, CngKeyHandleOpenOptions)

Crea un'istanza di un oggetto CngKey utilizzando un handle per una chiave esistente.

public:
 static System::Security::Cryptography::CngKey ^ Open(Microsoft::Win32::SafeHandles::SafeNCryptKeyHandle ^ keyHandle, System::Security::Cryptography::CngKeyHandleOpenOptions keyHandleOpenOptions);
public static System.Security.Cryptography.CngKey Open (Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle keyHandle, System.Security.Cryptography.CngKeyHandleOpenOptions keyHandleOpenOptions);
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public static System.Security.Cryptography.CngKey Open (Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle keyHandle, System.Security.Cryptography.CngKeyHandleOpenOptions keyHandleOpenOptions);
[System.Security.SecurityCritical]
public static System.Security.Cryptography.CngKey Open (Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle keyHandle, System.Security.Cryptography.CngKeyHandleOpenOptions keyHandleOpenOptions);
static member Open : Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle * System.Security.Cryptography.CngKeyHandleOpenOptions -> System.Security.Cryptography.CngKey
[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]
static member Open : Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle * System.Security.Cryptography.CngKeyHandleOpenOptions -> System.Security.Cryptography.CngKey
[<System.Security.SecurityCritical>]
static member Open : Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle * System.Security.Cryptography.CngKeyHandleOpenOptions -> System.Security.Cryptography.CngKey
Public Shared Function Open (keyHandle As SafeNCryptKeyHandle, keyHandleOpenOptions As CngKeyHandleOpenOptions) As CngKey

Parametri

keyHandle
SafeNCryptKeyHandle

Handle per una chiave esistente.

keyHandleOpenOptions
CngKeyHandleOpenOptions

Uno dei valori di enumerazione che indica se l'oggetto keyHandle rappresenta una chiave effimera o una chiave denominata.

Restituisce

CngKey

Chiave esistente.

Attributi

Eccezioni

keyHandle è null.

keyHandle è non valido o in formato non corretto, oppure è già chiuso. Questa eccezione viene inoltre generata se la chiave è una chiave effimera creata da Common Language Runtime (CLR), ma il valore EphemeralKey non viene specificato.

Cryptography Next Generation non è supportato in questo sistema.

Tutti gli altri errori.

Commenti

Questo overload consente agli utenti avanzati di usare le classi CNG anche se si basano su platform invoke o sulla funzionalità di interoperabilità gestita di C++. Ad esempio, se si dispone di una libreria nativa che restituisce la chiave come NCRYPT_KEY_HANDLE, questo overload consente di creare un wrapper gestito intorno alla chiave e di usare le classi CNG per modificarla.

Quando si apre una chiave usando il relativo handle, non è possibile determinare lo stato temporaneo della chiave e specificarlo manualmente. Diverse proprietà della CngKey classe si basano su questo valore per essere corrette. Assicurarsi quindi di passare il valore del flag corretto ai Open metodi .

Si applica a

Open(String, CngProvider)

Crea un'istanza di un oggetto CngKey che rappresenta una chiave denominata esistente, utilizzando il provider di archiviazione chiavi (KSP) specificato.

public:
 static System::Security::Cryptography::CngKey ^ Open(System::String ^ keyName, System::Security::Cryptography::CngProvider ^ provider);
public static System.Security.Cryptography.CngKey Open (string keyName, System.Security.Cryptography.CngProvider provider);
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public static System.Security.Cryptography.CngKey Open (string keyName, System.Security.Cryptography.CngProvider provider);
static member Open : string * System.Security.Cryptography.CngProvider -> System.Security.Cryptography.CngKey
[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]
static member Open : string * System.Security.Cryptography.CngProvider -> System.Security.Cryptography.CngKey
Public Shared Function Open (keyName As String, provider As CngProvider) As CngKey

Parametri

keyName
String

Nome della chiave.

provider
CngProvider

Provider archiviazione chiavi che contiene la chiave.

Restituisce

CngKey

Chiave esistente.

Attributi

Eccezioni

keyName o provider è null.

Cryptography Next Generation non è supportato in questo sistema.

Tutti gli altri errori.

Commenti

A differenza dell'overload del Open(String) metodo, questo overload consente di specificare il provider. Viene inoltre creato un valore predefinito CngKeyOpenOptions di None e associato alla chiave.

Si applica a

Open(String, CngProvider, CngKeyOpenOptions)

Crea un'istanza di un oggetto CngKey che rappresenta una chiave denominata esistente, utilizzando il provider di archiviazione chiavi (KSP) e le opzioni di apertura della chiave specificati.

public:
 static System::Security::Cryptography::CngKey ^ Open(System::String ^ keyName, System::Security::Cryptography::CngProvider ^ provider, System::Security::Cryptography::CngKeyOpenOptions openOptions);
public static System.Security.Cryptography.CngKey Open (string keyName, System.Security.Cryptography.CngProvider provider, System.Security.Cryptography.CngKeyOpenOptions openOptions);
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public static System.Security.Cryptography.CngKey Open (string keyName, System.Security.Cryptography.CngProvider provider, System.Security.Cryptography.CngKeyOpenOptions openOptions);
[System.Security.SecurityCritical]
public static System.Security.Cryptography.CngKey Open (string keyName, System.Security.Cryptography.CngProvider provider, System.Security.Cryptography.CngKeyOpenOptions openOptions);
static member Open : string * System.Security.Cryptography.CngProvider * System.Security.Cryptography.CngKeyOpenOptions -> System.Security.Cryptography.CngKey
[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]
static member Open : string * System.Security.Cryptography.CngProvider * System.Security.Cryptography.CngKeyOpenOptions -> System.Security.Cryptography.CngKey
[<System.Security.SecurityCritical>]
static member Open : string * System.Security.Cryptography.CngProvider * System.Security.Cryptography.CngKeyOpenOptions -> System.Security.Cryptography.CngKey
Public Shared Function Open (keyName As String, provider As CngProvider, openOptions As CngKeyOpenOptions) As CngKey

Parametri

keyName
String

Nome della chiave.

provider
CngProvider

Provider archiviazione chiavi che contiene la chiave.

openOptions
CngKeyOpenOptions

Combinazione bit per bit dei valori di enumerazione che specificano le opzioni di apertura della chiave, ad esempio se la chiave viene aperta dal computer o dall'archivio utente e se eliminare il prompt dell'interfaccia utente.

Restituisce

CngKey

Chiave esistente.

Attributi

Eccezioni

keyName o provider è null.

Cryptography Next Generation non è supportato in questo sistema.

Tutti gli altri errori.

Commenti

A differenza dell'overload del Open(String) metodo, questo overload consente di specificare sia il provider che le opzioni di apertura della chiave.

Si applica a