CngKey.Open 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
创建表示现有键的对象实例 CngKey 。
重载
| 名称 | 说明 |
|---|---|
| Open(String) |
创建表示现有命名键的对象实例 CngKey 。 |
| Open(SafeNCryptKeyHandle, CngKeyHandleOpenOptions) |
使用现有键的 CngKey 句柄创建对象的实例。 |
| Open(String, CngProvider) |
使用指定的密钥存储提供程序(KSP)创建表示现有命名密钥的对象实例 CngKey 。 |
| Open(String, CngProvider, CngKeyOpenOptions) |
使用指定的密钥存储提供程序(KSP)和密钥打开选项创建表示现有命名密钥的对象实例 CngKey 。 |
Open(String)
- Source:
- Cng.NotSupported.cs
- Source:
- Cng.NotSupported.cs
- Source:
- Cng.NotSupported.cs
- Source:
- Cng.NotSupported.cs
- Source:
- Cng.NotSupported.cs
创建表示现有命名键的对象实例 CngKey 。
public:
static System::Security::Cryptography::CngKey ^ Open(System::String ^ keyName);
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public static System.Security.Cryptography.CngKey Open(string keyName);
public static System.Security.Cryptography.CngKey Open(string keyName);
[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]
static member Open : string -> System.Security.Cryptography.CngKey
static member Open : string -> System.Security.Cryptography.CngKey
Public Shared Function Open (keyName As String) As CngKey
参数
- keyName
- String
密钥的名称。
返回
现有密钥。
- 属性
例外
keyName 是 null。
此系统上不支持下一代加密(CNG)。
所有其他错误。
注解
此重载使用以下默认值:
密钥存储提供程序 (KSP): MicrosoftSoftwareKeyStorageProvider。 Open(String, CngProvider)如果要指定另一个 KSP,请使用重载。
键打开选项: CngKeyOpenOptions.None.
适用于
Open(SafeNCryptKeyHandle, CngKeyHandleOpenOptions)
- Source:
- Cng.NotSupported.cs
- Source:
- Cng.NotSupported.cs
- Source:
- Cng.NotSupported.cs
- Source:
- Cng.NotSupported.cs
- Source:
- Cng.NotSupported.cs
使用现有键的 CngKey 句柄创建对象的实例。
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);
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);
[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]
static member Open : Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle * System.Security.Cryptography.CngKeyHandleOpenOptions -> System.Security.Cryptography.CngKey
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
参数
- keyHandle
- SafeNCryptKeyHandle
现有密钥的句柄。
- keyHandleOpenOptions
- CngKeyHandleOpenOptions
枚举值之一,该值指示是表示临时键还是 keyHandle 命名键。
返回
现有密钥。
- 属性
例外
keyHandle 是 null。
keyHandle 无效或格式不正确,或者已关闭。 如果密钥是由公共语言运行时 (CLR) 创建的临时键,但 EphemeralKey 未指定值,则也会引发此异常。
此系统上不支持下一代加密(CNG)。
所有其他错误。
注解
此重载使高级用户能够使用 CNG 类,即使它们依赖于平台调用或 C++ 的托管互操作功能。 例如,如果本机库将密钥作为NCRYPT_KEY_HANDLE返回,则此重载允许围绕密钥创建托管包装器,并使用 CNG 类对其进行操作。
使用密钥句柄打开密钥时,无法确定密钥的临时状态,并且必须自行指定密钥。 类的 CngKey 多个属性依赖于此值是正确的。 因此,请确保将正确的标志值传递给 Open 方法。
适用于
Open(String, CngProvider)
- Source:
- Cng.NotSupported.cs
- Source:
- Cng.NotSupported.cs
- Source:
- Cng.NotSupported.cs
- Source:
- Cng.NotSupported.cs
- Source:
- Cng.NotSupported.cs
使用指定的密钥存储提供程序(KSP)创建表示现有命名密钥的对象实例 CngKey 。
public:
static System::Security::Cryptography::CngKey ^ Open(System::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);
public static System.Security.Cryptography.CngKey Open(string keyName, System.Security.Cryptography.CngProvider provider);
[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]
static member Open : string * System.Security.Cryptography.CngProvider -> System.Security.Cryptography.CngKey
static member Open : string * System.Security.Cryptography.CngProvider -> System.Security.Cryptography.CngKey
Public Shared Function Open (keyName As String, provider As CngProvider) As CngKey
参数
- keyName
- String
密钥的名称。
- provider
- CngProvider
包含密钥的 KSP。
返回
现有密钥。
- 属性
例外
keyName 或 provider 为 null.
此系统上不支持下一代加密(CNG)。
所有其他错误。
注解
Open(String)与方法重载不同,此重载允许你指定提供程序。 此外,还会创建默认值CngKeyOpenOptionsNone并将其绑定到密钥。
适用于
Open(String, CngProvider, CngKeyOpenOptions)
- Source:
- Cng.NotSupported.cs
- Source:
- Cng.NotSupported.cs
- Source:
- Cng.NotSupported.cs
- Source:
- Cng.NotSupported.cs
- Source:
- Cng.NotSupported.cs
使用指定的密钥存储提供程序(KSP)和密钥打开选项创建表示现有命名密钥的对象实例 CngKey 。
public:
static System::Security::Cryptography::CngKey ^ Open(System::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);
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);
[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]
static member Open : string * System.Security.Cryptography.CngProvider * System.Security.Cryptography.CngKeyOpenOptions -> System.Security.Cryptography.CngKey
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
参数
- keyName
- String
密钥的名称。
- provider
- CngProvider
包含密钥的 KSP。
- openOptions
- CngKeyOpenOptions
枚举值的按位组合,指定用于打开键的选项,例如从(计算机或用户存储)打开密钥的位置以及是否禁止显示 UI 提示。
返回
现有密钥。
- 属性
例外
keyName 或 provider 为 null.
此系统上不支持下一代加密(CNG)。
所有其他错误。
注解
Open(String)与方法重载不同,此重载允许你同时指定提供程序和密钥打开选项。