예제 #1
0
        public bool AddShouldTrustServerCertificateToDbConnectionStringBuilder(bool encrypt, string auth, string server)
        {
            var builder = new DbConnectionStringBuilder
            {
                ["Server"] = server,
            };

            if (encrypt)
            {
                builder["Encrypt"] = "true";
            }

            if (auth != null)
            {
                builder["Authentication"] = auth;
            }

            builder.SetBackwardsCompatibleTrustServerCertificateValue();
            return(new SqlConnectionStringBuilder(builder.ConnectionString).TrustServerCertificate);
        }