/// <summary>
        /// Creates an <see cref="Func{X509Certificate2Collection}"/> given <see cref="CertificateStoreOptions"/> to find a .pfx
        /// certificate in the Windows Cert Store.
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        public static Func <X509Certificate2Collection> GetCertificatesFromStore(CertificateStoreOptions options)
        {
            return(() =>
            {
                if (options == null)
                {
                    throw new ArgumentNullException(nameof(options));
                }

                var store = new X509Store(options.StoreName, options.StoreLocation);
                store.Open(OpenFlags.ReadOnly);
                return store.Certificates.Find(options.X509FindType, options.FindValue, false);
            });
        }
 public CertAuthenticator(CertificateStoreOptions options)
 {
     CertificateFunc = CertificateFactory.GetCertificatesFromStore(options);
 }