Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

class System.​Security.​Cryptography.​X509Certificates.​X509Certificate2Collection

Assembly: System.Security.Cryptography

Inheritance: object → Collections.​CollectionBaseX509CertificateCollection → X509Certificate2Collection

Implemented Interfaces

Represents a collection of <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2" /> objects. This class cannot be inherited.

Properties

Item
Item
public int
Capacity
public int
Count
InnerList
List

Methods

public int
Add​(X509Certificate2 certificate)
Adds an object to the end of the <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2Collection" /> .
Returns The <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2Collection" /> index at which the <paramref name="certificate" /> has been added.
certificate An X.509 certificate represented as an <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2" /> object.
public void
AddRange​(X509Certificate2Collection certificates)
Adds multiple <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2" /> objects in an <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2Collection" /> object to another <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2Collection" /> object.
certificates An <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2Collection" /> object.
public void
AddRange​(X509Certificate2[] certificates)
Adds multiple <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2" /> objects in an array to the <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2Collection" /> object.
certificates An array of <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2" /> objects.
public bool
Contains​(X509Certificate2 certificate)
Determines whether the <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2Collection" /> object contains a specific certificate.
Returns <see langword="true" /> if the <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2Collection" /> contains the specified <paramref name="certificate" /> ; otherwise, <see langword="false" /> .
certificate The <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2" /> object to locate in the collection.
public byte[]
Export​(X509ContentType contentType)
Exports X.509 certificate information into a byte array.
Returns X.509 certificate information in a byte array.
contentType A supported <see cref="T:System.Security.Cryptography.X509Certificates.X509ContentType" /> object.
public byte[]
Export​(X509ContentType contentType, string password)
Exports X.509 certificate information into a byte array using a password.
Returns X.509 certificate information in a byte array.
contentType A supported <see cref="T:System.Security.Cryptography.X509Certificates.X509ContentType" /> object.
password A string used to protect the byte array.
public string
ExportCertificatePems​()
Exports the public X.509 certificates, encoded as PEM.
Returns The PEM encoding of the certificates.
public byte[]
ExportPkcs12​(PbeParameters exportParameters, string password)
Exports the certificates and private keys in PKCS#12 / PFX format.
Returns A byte array containing the encoded PKCS#12.
exportParameters The algorithm parameters to use for the export.
password The password to use for the export.
public byte[]
ExportPkcs12​(Pkcs12ExportPbeParameters exportParameters, string password)
Exports the certificate and private key in PKCS#12 / PFX format.
Returns A byte array containing the encoded PKCS#12.
exportParameters The algorithm parameters to use for the export.
password The password to use for the export.
public string
ExportPkcs7Pem​()
Exports the X.509 public certificates as a PKCS7 certificate collection, encoded as PEM.
Returns The PEM encoded PKCS7 collection.
Find​(X509FindType findType, object findValue, bool validOnly)
Searches an <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2Collection" /> object using the search criteria specified by the <see cref="T:System.Security.Cryptography.X509Certificates.X509FindType" /> enumeration and the <paramref name="findValue" /> object.
Returns An <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2Collection" /> object.
findType One of the <see cref="T:System.Security.Cryptography.X509Certificates.X509FindType" /> values.
findValue The search criteria as an object.
validOnly <see langword="true" /> to allow only valid certificates to be returned from the search; otherwise, <see langword="false" /> .
FindByThumbprint​(HashAlgorithmName hashAlgorithm, ReadOnlySpan<​byte> thumbprintBytes)
Searches the collection for certificates with a matching thumbprint.
Returns A collection of certificates with a matching thumbprint.
hashAlgorithm The name of the hash algorithm to compute the thumbprint.
thumbprintBytes The thumbprint to match.
FindByThumbprint​(HashAlgorithmName hashAlgorithm, ReadOnlySpan<​char> thumbprintHex)
Searches the collection for certificates with a matching thumbprint.
Returns A collection of certificates with a matching thumbprint.
hashAlgorithm The name of the hash algorithm to compute the thumbprint.
thumbprintHex The thumbprint to match, hex-encoded.
FindByThumbprint​(HashAlgorithmName hashAlgorithm, string thumbprintHex)
Searches the collection for certificates with a matching thumbprint.
Returns A collection of certificates with a matching thumbprint.
hashAlgorithm The name of the hash algorithm to compute the thumbprint.
thumbprintHex The thumbprint to match, hex-encoded.
GetEnumerator​()
Returns an enumerator that can iterate through a <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2Collection" /> object.
Returns An <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2Enumerator" /> object that can iterate through the <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2Collection" /> object.
public void
Import​(byte[] rawData)
Imports a certificate in the form of a byte array into a <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2Collection" /> object.
rawData A byte array containing data from an X.509 certificate.
public void
Import​(byte[] rawData, string password, X509KeyStorageFlags keyStorageFlags = 0)
Imports a certificate, in the form of a byte array that requires a password to access the certificate, into a <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2Collection" /> object.
rawData A byte array containing data from an <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2" /> object.
password The password required to access the certificate information.
keyStorageFlags A bitwise combination of the enumeration values that control how and where the certificate is imported.
public void
Import​(ReadOnlySpan<​byte> rawData)
Imports the certificates from the provided data into this collection.
rawData The certificate data to read.
public void
Import​(ReadOnlySpan<​byte> rawData, ReadOnlySpan<​char> password, X509KeyStorageFlags keyStorageFlags = 0)
Imports the certificates from the provided data into this collection.
rawData The certificate data to read.
password The password required to access the certificate data.
keyStorageFlags A bitwise combination of the enumeration values that control where and how to import the certificate.
public void
Import​(ReadOnlySpan<​byte> rawData, string password, X509KeyStorageFlags keyStorageFlags = 0)
Imports the certificates from the provided data into this collection.
rawData The certificate data to read.
password The password required to access the certificate data.
keyStorageFlags A bitwise combination of the enumeration values that control where and how to import the certificate.
public void
Import​(string fileName)
Imports a certificate file into a <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2Collection" /> object.
fileName The name of the file containing the certificate information.
public void
Import​(string fileName, ReadOnlySpan<​char> password, X509KeyStorageFlags keyStorageFlags = 0)
Imports the certificates from the specified file a into this collection.
fileName The name of the file containing the certificate information.
password The password required to access the certificate data.
keyStorageFlags A bitwise combination of the enumeration values that control where and how to import the certificate.
public void
Import​(string fileName, string password, X509KeyStorageFlags keyStorageFlags = 0)
Imports a certificate file that requires a password into a <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2Collection" /> object.
fileName The name of the file containing the certificate information.
password The password required to access the certificate information.
keyStorageFlags A bitwise combination of the enumeration values that control how and where the certificate is imported.
public void
ImportFromPem​(ReadOnlySpan<​char> certPem)
Imports a collection of RFC 7468 PEM-encoded certificates.
certPem The text of the PEM-encoded X509 certificate collection.
public void
ImportFromPemFile​(string certPemFilePath)
Imports a collection of RFC 7468 PEM-encoded certificates.
certPemFilePath The path for the PEM-encoded X509 certificate collection.
public void
Insert​(int index, X509Certificate2 certificate)
Inserts an object into the <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2Collection" /> object at the specified index.
index The zero-based index at which to insert <paramref name="certificate" /> .
certificate The <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2" /> object to insert.
public void
Remove​(X509Certificate2 certificate)
Removes the first occurrence of a certificate from the <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2Collection" /> object.
certificate The <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2" /> object to be removed from the <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2Collection" /> object.
public void
RemoveRange​(X509Certificate2Collection certificates)
Removes multiple <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2" /> objects in an <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2Collection" /> object from another <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2Collection" /> object.
certificates An <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2Collection" /> object.
public void
RemoveRange​(X509Certificate2[] certificates)
Removes multiple <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2" /> objects in an array from an <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2Collection" /> object.
certificates An array of <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2" /> objects.
public bool
TryExportCertificatePems​(Span<​char> destination, Int32& charsWritten)
public bool
TryExportPkcs7Pem​(Span<​char> destination, Int32& charsWritten)
public int
Add​(X509Certificate value)
Inherited from X509CertificateCollection
Adds an <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> with the specified value to the current <see cref="T:System.Security.Cryptography.X509Certificates.X509CertificateCollection" /> .
Returns The index into the current <see cref="T:System.Security.Cryptography.X509Certificates.X509CertificateCollection" /> at which the new <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> was inserted.
value The <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> to add to the current <see cref="T:System.Security.Cryptography.X509Certificates.X509CertificateCollection" /> .
public void
AddRange​(X509CertificateCollection value)
Inherited from X509CertificateCollection
Copies the elements of the specified <see cref="T:System.Security.Cryptography.X509Certificates.X509CertificateCollection" /> to the end of the current <see cref="T:System.Security.Cryptography.X509Certificates.X509CertificateCollection" /> .
value The <see cref="T:System.Security.Cryptography.X509Certificates.X509CertificateCollection" /> containing the objects to add to the collection.
public void
AddRange​(X509Certificate[] value)
Inherited from X509CertificateCollection
Copies the elements of an array of type <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> to the end of the current <see cref="T:System.Security.Cryptography.X509Certificates.X509CertificateCollection" /> .
value The array of type <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> containing the objects to add to the current <see cref="T:System.Security.Cryptography.X509Certificates.X509CertificateCollection" /> .
public bool
Contains​(X509Certificate value)
Inherited from X509CertificateCollection
Gets a value indicating whether the current <see cref="T:System.Security.Cryptography.X509Certificates.X509CertificateCollection" /> contains the specified <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> .
Returns <see langword="true" /> if the <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> is contained in this collection; otherwise, <see langword="false" /> .
value The <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> to locate.
public void
CopyTo​(X509Certificate[] array, int index)
Inherited from X509CertificateCollection
Copies the <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> values in the current <see cref="T:System.Security.Cryptography.X509Certificates.X509CertificateCollection" /> to a one-dimensional <see cref="T:System.Array" /> instance at the specified index.
array The one-dimensional <see cref="T:System.Array" /> that is the destination of the values copied from <see cref="T:System.Security.Cryptography.X509Certificates.X509CertificateCollection" /> .
index The index into <paramref name="array" /> to begin copying.
GetEnumerator​()
Inherited from X509CertificateCollection
Returns an enumerator that can iterate through the <see cref="T:System.Security.Cryptography.X509Certificates.X509CertificateCollection" /> .
Returns An enumerator of the subelements of <see cref="T:System.Security.Cryptography.X509Certificates.X509CertificateCollection" /> you can use to iterate through the collection.
public int
GetHashCode​()
Inherited from X509CertificateCollection
Builds a hash value based on all values contained in the current <see cref="T:System.Security.Cryptography.X509Certificates.X509CertificateCollection" /> .
Returns A hash value based on all values contained in the current <see cref="T:System.Security.Cryptography.X509Certificates.X509CertificateCollection" /> .
public int
IndexOf​(X509Certificate value)
Inherited from X509CertificateCollection
Returns the index of the specified <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> in the current <see cref="T:System.Security.Cryptography.X509Certificates.X509CertificateCollection" /> .
Returns The index of the <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> specified by the <paramref name="value" /> parameter in the <see cref="T:System.Security.Cryptography.X509Certificates.X509CertificateCollection" /> , if found; otherwise, -1.
value The <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> to locate.
public void
Insert​(int index, X509Certificate value)
Inherited from X509CertificateCollection
Inserts a <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> into the current <see cref="T:System.Security.Cryptography.X509Certificates.X509CertificateCollection" /> at the specified index.
index The zero-based index where <paramref name="value" /> should be inserted.
value The <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> to insert.
protected void
OnValidate​(object value)
Inherited from X509CertificateCollection
Performs additional custom processes when validating a value.
value The object to validate.
public void
Remove​(X509Certificate value)
Inherited from X509CertificateCollection
Removes a specific <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> from the current <see cref="T:System.Security.Cryptography.X509Certificates.X509CertificateCollection" /> .
value The <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> to remove from the current <see cref="T:System.Security.Cryptography.X509Certificates.X509CertificateCollection" /> .
public void
Clear​()
GetEnumerator​()
protected void
OnClear​()
protected void
OnClearComplete​()
protected void
OnInsert​(int index, object value)
protected void
OnInsertComplete​(int index, object value)
protected void
OnRemove​(int index, object value)
protected void
OnRemoveComplete​(int index, object value)
protected void
OnSet​(int index, object oldValue, object newValue)
protected void
OnSetComplete​(int index, object oldValue, object newValue)
public void
RemoveAt​(int index)
public bool
Equals​(object obj)
Inherited from object
protected void
Finalize​()
Inherited from object
public Type
GetType​()
Inherited from object
protected object
MemberwiseClone​()
Inherited from object
public string
ToString​()
Inherited from object