<PackageReference Include="System.Security.Cryptography.Pkcs" Version="10.0.12" />

System.Security.Cryptography.Pkcs.Pkcs12SafeBag

public abstract class Pkcs12SafeBag
Defines the core behavior of a SafeBag value from the PKCS#12 specification and provides a base for derived classes.

Gets the modifiable collection of attributes to encode with the SafeBag value.

public ReadOnlyMemory<byte> EncodedBagValue { get; }

Gets the ASN.1 BER encoding of the contents of this SafeBag.

protected Pkcs12SafeBag(string bagIdValue, ReadOnlyMemory<byte> encodedBagValue, bool skipCopy = false)

Called from constructors in derived classes to initialize the Pkcs12SafeBag class.

public byte[] Encode()

Encodes the SafeBag value and returns it as a byte array.

public Oid GetBagId()

Gets the Object Identifier (OID) identifying the content type of this SafeBag.

public bool TryEncode(Span<byte> destination, out int bytesWritten)

Attempts to encode the SafeBag value into a provided buffer.