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.CollectionBase → X509CertificateCollection → X509Certificate2Collection
Represents a collection of <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2" /> objects. This class cannot be inherited.
Properties
public
X509Certificate2
Item
public
X509Certificate
Item
public
int
Capacity
public
int
Count
protected
Collections.​ArrayList
InnerList
protected
Collections.​IList
List
Methods
public
int
Add​(X509Certificate2 certificate)
certificate
An X.509 certificate represented as an <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2" /> object.
Returns The <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2Collection" /> index at which the <paramref name="certificate" /> has been added.
Adds an object to the end of the <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2Collection" /> .
public
void
AddRange​(X509Certificate2Collection certificates)
certificates
An <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2Collection" /> object.
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.
public
void
AddRange​(X509Certificate2[] certificates)
certificates
An array of <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2" /> objects.
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.
public
bool
Contains​(X509Certificate2 certificate)
certificate
The <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2" /> object to locate in the collection.
Returns <see langword="true" /> if the <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2Collection" /> contains the specified <paramref name="certificate" /> ; otherwise, <see langword="false" /> .
Determines whether the <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2Collection" /> object contains a specific certificate.
public
byte[]
Export​(X509ContentType contentType)
contentType
A supported <see cref="T:System.Security.Cryptography.X509Certificates.X509ContentType" /> object.
Returns X.509 certificate information in a byte array.
Exports X.509 certificate information into a byte array.
public
byte[]
Export​(X509ContentType contentType,
string password)
contentType
A supported <see cref="T:System.Security.Cryptography.X509Certificates.X509ContentType" /> object.
password
A string used to protect the byte array.
Returns X.509 certificate information in a byte array.
Exports X.509 certificate information into a byte array using a password.
public
string
ExportCertificatePems​() Returns The PEM encoding of the certificates.
Exports the public X.509 certificates, encoded as PEM.
public
byte[]
ExportPkcs12​(PbeParameters exportParameters,
string password)
exportParameters
The algorithm parameters to use for the export.
password
The password to use for the export.
Returns A byte array containing the encoded PKCS#12.
Exports the certificates and private keys in PKCS#12 / PFX format.
public
byte[]
ExportPkcs12​(Pkcs12ExportPbeParameters exportParameters,
string password)
exportParameters
The algorithm parameters to use for the export.
password
The password to use for the export.
Returns A byte array containing the encoded PKCS#12.
Exports the certificate and private key in PKCS#12 / PFX format.
public
string
ExportPkcs7Pem​() Returns The PEM encoded PKCS7 collection.
Exports the X.509 public certificates as a PKCS7 certificate collection, encoded as PEM.
public
X509Certificate2Collection
Find​(X509FindType findType,
object findValue,
bool validOnly)
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" /> .
Returns An <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2Collection" /> object.
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.
public
X509Certificate2Collection
FindByThumbprint​(HashAlgorithmName hashAlgorithm,
ReadOnlySpan`1 thumbprintBytes)
public
X509Certificate2Collection
FindByThumbprint​(HashAlgorithmName hashAlgorithm,
ReadOnlySpan`1 thumbprintHex)
public
X509Certificate2Collection
FindByThumbprint​(HashAlgorithmName hashAlgorithm,
string thumbprintHex)
hashAlgorithm
The name of the hash algorithm to compute the thumbprint.
thumbprintHex
The thumbprint to match, hex-encoded.
Returns A collection of certificates with a matching thumbprint.
Searches the collection for certificates with a matching thumbprint.
public
X509Certificate2Enumerator
GetEnumerator​() 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.
Returns an enumerator that can iterate through a <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2Collection" /> object.
public
void
Import​(byte[] rawData)
rawData
A byte array containing data from an X.509 certificate.
Imports a certificate in the form of a byte array into a <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2Collection" /> object.
public
void
Import​(byte[] rawData,
string password,
X509KeyStorageFlags keyStorageFlags = 0)
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.
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.
public
void
Import​(ReadOnlySpan`1 rawData,
ReadOnlySpan`1 password,
X509KeyStorageFlags keyStorageFlags = 0)
public
void
Import​(ReadOnlySpan`1 rawData,
string password,
X509KeyStorageFlags keyStorageFlags = 0)
public
void
Import​(string fileName)
fileName
The name of the file containing the certificate information.
Imports a certificate file into a <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2Collection" /> object.
public
void
Import​(string fileName,
ReadOnlySpan`1 password,
X509KeyStorageFlags keyStorageFlags = 0)
public
void
Import​(string fileName,
string password,
X509KeyStorageFlags keyStorageFlags = 0)
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.
Imports a certificate file that requires a password into a <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2Collection" /> object.
public
void
ImportFromPemFile​(string certPemFilePath)
certPemFilePath
The path for the PEM-encoded X509 certificate collection.
Imports a collection of RFC 7468 PEM-encoded certificates.
public
void
Insert​(int index,
X509Certificate2 certificate)
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.
Inserts an object into the <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2Collection" /> object at the specified index.
public
void
Remove​(X509Certificate2 certificate)
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.
Removes the first occurrence of a certificate from the <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2Collection" /> object.
public
void
RemoveRange​(X509Certificate2Collection certificates)
certificates
An <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2Collection" /> object.
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.
public
void
RemoveRange​(X509Certificate2[] certificates)
certificates
An array of <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2" /> objects.
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.
public
int
Add​(X509Certificate value)
Inherited from X509CertificateCollection
value
The <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> to add 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.
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" /> .
public
void
AddRange​(X509CertificateCollection value)
Inherited from X509CertificateCollection
value
The <see cref="T:System.Security.Cryptography.X509Certificates.X509CertificateCollection" /> containing the objects to add to the collection.
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" /> .
public
void
AddRange​(X509Certificate[] value)
Inherited from 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" /> .
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" /> .
public
bool
Contains​(X509Certificate value)
Inherited from X509CertificateCollection
value
The <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> to locate.
Returns <see langword="true" /> if the <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> is contained in this collection; otherwise, <see langword="false" /> .
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" /> .
public
void
CopyTo​(X509Certificate[] array,
int index)
Inherited from X509CertificateCollection
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.
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.
public
X509CertificateEnumerator
GetEnumerator​()
Inherited from X509CertificateCollection
Returns An enumerator of the subelements of <see cref="T:System.Security.Cryptography.X509Certificates.X509CertificateCollection" /> you can use to iterate through the collection.
Returns an enumerator that can iterate through the <see cref="T:System.Security.Cryptography.X509Certificates.X509CertificateCollection" /> .
public
int
GetHashCode​()
Inherited from X509CertificateCollection
Returns A hash value based on all values contained in the current <see cref="T:System.Security.Cryptography.X509Certificates.X509CertificateCollection" /> .
Builds 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
value
The <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> to locate.
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.
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" /> .
public
void
Insert​(int index,
X509Certificate value)
Inherited from X509CertificateCollection
index
The zero-based index where <paramref name="value" /> should be inserted.
value
The <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> to insert.
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.
protected
void
OnValidate​(object value)
Inherited from X509CertificateCollection
value
The object to validate.
Performs additional custom processes when validating a value.
public
void
Remove​(X509Certificate value)
Inherited from X509CertificateCollection
value
The <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> to remove from the current <see cref="T:System.Security.Cryptography.X509Certificates.X509CertificateCollection" /> .
Removes a specific <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> from the current <see cref="T:System.Security.Cryptography.X509Certificates.X509CertificateCollection" /> .
protected
void
OnInsertComplete​(int index,
object value)
Inherited from CollectionBase
protected
void
OnRemoveComplete​(int index,
object value)
Inherited from CollectionBase
protected
void
OnSet​(int index,
object oldValue,
object newValue)
Inherited from CollectionBase
protected
void
OnSetComplete​(int index,
object oldValue,
object newValue)
Inherited from CollectionBase
public
bool
Equals​(object obj)
Inherited from object
protected
void
Finalize​()
Inherited from object
protected
object
MemberwiseClone​()
Inherited from object
public
string
ToString​()
Inherited from object