Example #1
0
        private X509Certificate2 GetCertificate()
        {
            var path = Settings["Raven/OAuthTokenCertificatePath"];

            if (string.IsNullOrEmpty(path) == false)
            {
                path = path.ToFullPath();
                var pwd = Settings["Raven/OAuthTokenCertificatePassword"];
                if (string.IsNullOrEmpty(pwd) == false)
                {
                    try
                    {
                        return(new X509Certificate2(path, pwd));
                    }
                    catch (Exception)
                    {
                        return(new X509Certificate2(path, pwd, X509KeyStorageFlags.MachineKeySet));
                    }
                }
                try
                {
                    return(new X509Certificate2(path));
                }
                catch (Exception)
                {
                    return(new X509Certificate2(path, string.Empty, X509KeyStorageFlags.MachineKeySet));
                }
            }

            return(CertGenerator.GenerateNewCertificate("RavenDB"));
        }
        private X509Certificate2 GetCertificate()
        {
            var path = Settings["Raven/OAuthTokenCertificatePath"];

            if (string.IsNullOrEmpty(path) == false)
            {
                var pwd = Settings["Raven/OAuthTokenCertificatePassword"];
                if (string.IsNullOrEmpty(pwd) == false)
                {
                    return(new X509Certificate2(path, pwd));
                }
                return(new X509Certificate2(path));
            }

            return(CertGenerator.GenerateNewCertificate("RavenDB"));
        }