Export (0) Print
Expand All

X509Store Class

Represents an X.509 store, which is a physical store where certificates are persisted and managed. This class cannot be inherited.

System.Object
  System.Security.Cryptography.X509Certificates.X509Store

Namespace:  System.Security.Cryptography.X509Certificates
Assembly:  System (in System.dll)

[<Sealed>]
type X509Store =  
    class 
        interface IDisposable 
    end

The X509Store type exposes the following members.

  NameDescription
Public methodX509Store()Initializes a new instance of the X509Store class using the personal certificates of the current user store.
Public methodX509Store(IntPtr)Initializes a new instance of the X509Store class using an Intptr handle to an HCERTSTORE store.
Public methodX509Store(StoreLocation)Initializes a new instance of the X509Store class using the specified StoreLocation value.
Public methodX509Store(StoreName)Initializes a new instance of the X509Store class using the specified StoreName value.
Public methodX509Store(String)Initializes a new instance of the X509Store class using the specified store name.
Public methodX509Store(StoreName, StoreLocation)Initializes a new instance of the X509Store class using the specified StoreName and StoreLocation values.
Public methodX509Store(String, StoreLocation)Initializes a new instance of the X509Store class using a string that represents a value from the StoreName enumeration and a value from the StoreLocation enumeration.
Top

  NameDescription
Public propertyCertificatesReturns a collection of certificates located in an X.509 certificate store.
Public propertyLocationGets the location of the X.509 certificate store.
Public propertyNameGets the name of the X.509 certificate store.
Public propertyStoreHandleGets an IntPtr handle to an HCERTSTORE store.
Top

  NameDescription
Public methodAddAdds a certificate to an X.509 certificate store.
Public methodAddRangeAdds a collection of certificates to an X.509 certificate store.
Public methodCloseCloses an X.509 certificate store.
Public methodDisposeReleases the resources used by this X509Store.
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodOpenOpens an X.509 certificate store or creates a new store, depending on OpenFlags flag settings.
Public methodRemoveRemoves a certificate from an X.509 certificate store.
Public methodRemoveRangeRemoves a range of certificates from an X.509 certificate store.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

Use this class to work with an X.509 store.

Important noteImportant

This type implements the IDisposable interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its Dispose method in a try/catch block. To dispose of it indirectly, use a language construct such as using (in C#) or Using (in Visual Basic). For more information, see the “Using an Object that Implements IDisposable” section in the IDisposable interface topic.

This section contains two examples. The first example demonstrates how you can open standard X.509 stores and list the number of certificates in each.

The second example demonstrates how you can add and remove single certificates and ranges of certificates.

Example 1

This example tries to open each standard store in each standard location on the current computer. It prints a summary that shows whether each store exists and, if so, the number of certificates it contains.

The example creates an X509Store object for each combination of standard name and standard location. It calls the Open method with the OpenFlags.OpenExistingOnly flag, which opens the physical store only if it already exists. If the physical store exists, the example uses the Name, Location, and Certificates properties to display the number of certificates in the store.

No code example is currently available or this language may not be supported.

Example 2

This example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2015 Microsoft