Pkcs12KeyBag(ReadOnlyMemory<Byte>, Boolean) 构造函数
定义
从现有的编码 PKCS#8 PrivateKeyInfo 值初始化 Pkcs12KeyBag 的新实例。Initializes a new instance of the Pkcs12KeyBag from an existing encoded PKCS#8 PrivateKeyInfo value.
public Pkcs12KeyBag (ReadOnlyMemory<byte> pkcs8PrivateKey, bool skipCopy = false);
new System.Security.Cryptography.Pkcs.Pkcs12KeyBag : ReadOnlyMemory<byte> * bool -> System.Security.Cryptography.Pkcs.Pkcs12KeyBag
Public Sub New (pkcs8PrivateKey As ReadOnlyMemory(Of Byte), Optional skipCopy As Boolean = false)
参数
- pkcs8PrivateKey
- ReadOnlyMemory<Byte>
BER 编码的 PKCS#8 PrivateKeyInfo 值。A BER-encoded PKCS#8 PrivateKeyInfo value.
- skipCopy
- Boolean
true 表示存储 pkcs8PrivateKey 而不进行防御性复制;否则为 false。true to store pkcs8PrivateKey without making a defensive copy; otherwise, false. 默认值为 false。The default is false.
例外
pkcs8privateKey 参数不表示单个 ASN.1 BER 编码值。The pkcs8privateKey parameter does not represent a single ASN.1 BER-encoded value.
注解
此方法验证 pkcs8PrivateKey 是否为单 BER 编码值,但不验证该值是否为正确的 PKCS # 8 PrivateKeyInfo 值。This method validates that pkcs8PrivateKey is a single BER-encoded value, but it does not verify that the value is a proper PKCS#8 PrivateKeyInfo value.
PKCS # 12 标准版允许传输密钥包中的私钥,但并非所有 PFX 读取器都支持通过密钥包中的密钥配对证书。Transporting private keys in a KeyBag is permitted by the PKCS#12 standard, but not all PFX readers support pairing certificates with keys from a KeyBag. 为获得最佳支持,ShroudedKeyBag 中的传输密钥 Pkcs12ShroudedKeyBag) (。For best support, transport keys in a ShroudedKeyBag (Pkcs12ShroudedKeyBag).
此方法的默认行为是创建的一个防御副本 pkcs8PrivateKey 。The default behavior of this method is to make a defensive copy of pkcs8PrivateKey.
当 skipCopy 参数为时 true ,将跳过此防御副本。When the skipCopy parameter is true, this defensive copy is skipped.
如果在 pkcs8PrivateKey 返回值或其方法或属性生成的任何对象的生存期内跳过了防御复制,则这些对象的方法和属性可能会产生有意义的结果或引发异常,因为状态已损坏。If the defensive copy is skipped and the contents of pkcs8PrivateKey change during the lifetime of the returned value or of any object produced by its methods or properties, then methods and properties on those objects may produce nonsense results or throw exceptions due to the corrupted state.
因此,如果调用方 true skipCopy 可以合理地确保数据保持不变,则建议只使用参数值。Callers are therefore advised to only use a true value for the skipCopy parameter when they can be reasonably assured that the data will stay intact.