Opc.Ua.CertificateStoreIdentifier.OpenStore C# (CSharp) Method

OpenStore() public method

Returns an object that can be used to access the store.
public OpenStore ( ) : ICertificateStore
return ICertificateStore
        public ICertificateStore OpenStore()
        {
            ICertificateStore store = CreateStore(this.StoreType);
            store.Open(this.StorePath);
            return store;
        }

Same methods

CertificateStoreIdentifier::OpenStore ( string path ) : ICertificateStore

Usage Example

        public async Task<X509Certificate2Collection> GetCertificates()
        {
            X509Certificate2Collection collection = new X509Certificate2Collection();

            CertificateStoreIdentifier id = new CertificateStoreIdentifier();

            id.StoreType = this.StoreType;
            id.StorePath = this.StorePath;

            if (!String.IsNullOrEmpty(id.StorePath))
            {
                try
                {
                    ICertificateStore store = id.OpenStore();

                    try
                    {
                        collection = await store.Enumerate();
                    }
                    finally
                    {
                        store.Close();
                    }
                }
                catch (Exception)
                {
                    Utils.Trace("Could not load certificates from store: {0}.", this.StorePath);
                }
            }

            foreach (CertificateIdentifier trustedCertificate in TrustedCertificates)
            {
                X509Certificate2 certificate = await trustedCertificate.Find();

                if (certificate != null)
                {
                    collection.Add(certificate);
                }
            }

            return collection;
        }
All Usage Examples Of Opc.Ua.CertificateStoreIdentifier::OpenStore