Example #1
0
        public SvnError SslServerTrustAuth(out SvnAuthCredSslServerTrust cred,
                                           IntPtr baton, AprString realm,
                                           SvnAuthCredSslServerTrust.CertFailures failures,
                                           SvnAuthSslServerCertInfo certInfo,
                                           bool maySave, IntPtr pool)
        {
            this.Log(Level.Warning, "Error validating server certificate for '{0}':", realm);
            if ((failures & SvnAuthCredSslServerTrust.CertFailures.UnknownCA) > 0)
            {
                this.Log(Level.Warning, " - The certificate is not issued by a trusted authority");
            }
            if ((failures & SvnAuthCredSslServerTrust.CertFailures.CNMismatch) > 0)
            {
                this.Log(Level.Warning, " - The certificate hostname does not match");
            }
            if ((failures & SvnAuthCredSslServerTrust.CertFailures.NotYetValid) > 0)
            {
                this.Log(Level.Warning, " - The certificate is not yet valid");
            }
            if ((failures & SvnAuthCredSslServerTrust.CertFailures.Expired) > 0)
            {
                this.Log(Level.Warning, " - The certificate has expired");
            }
            if ((failures & SvnAuthCredSslServerTrust.CertFailures.Other) > 0)
            {
                this.Log(Level.Warning, " - The certificate has an unknown error");
            }

            this.Log(Level.Warning, "Certificate informations:");
            this.Log(Level.Warning, "\tHostName:    " + certInfo.Hostname);
            this.Log(Level.Warning, "\tIssuer:      " + certInfo.IssuerDName);
            this.Log(Level.Warning, "\tValid From:  " + certInfo.ValidFrom);
            this.Log(Level.Warning, "\tValid Until: " + certInfo.ValidUntil);
            this.Log(Level.Warning, "\tFingerprint: " + certInfo.Fingerprint);

            cred = SvnAuthCredSslServerTrust.Alloc(pool);

            if (this.AcceptCertificate == AcceptCertificate.Reject)
            {
                cred.AcceptedFailures = 0;
                cred.MaySave          = false;
            }
            else if (this.AcceptCertificate == AcceptCertificate.Temporarily)
            {
                cred.AcceptedFailures = failures;
                cred.MaySave          = false;
            }
            else if (this.AcceptCertificate == AcceptCertificate.Permanently)
            {
                cred.AcceptedFailures = failures;
                cred.MaySave          = true;
            }

            return(SvnError.NoError);
        }
Example #2
0
        public SvnError SslServerTrustAuth(out SvnAuthCredSslServerTrust cred,
                                           IntPtr baton, AprString realm,
                                           SvnAuthCredSslServerTrust.CertFailures failures,
                                           SvnAuthSslServerCertInfo certInfo,
                                           bool maySave, IntPtr pool)
        {
            Console.WriteLine("Ssl Server Trust Prompt:");
            Console.WriteLine("------------------------");
            Console.WriteLine("");

            Console.WriteLine("Error validating server certificate for '{0}':", realm);
            if ((failures & SvnAuthCredSslServerTrust.CertFailures.UnknownCA) > 0)
            {
                Console.WriteLine(" - The certificate is not issued by a trusted authority");
            }
            if ((failures & SvnAuthCredSslServerTrust.CertFailures.CNMismatch) > 0)
            {
                Console.WriteLine(" - The certificate hostname does not match");
            }
            if ((failures & SvnAuthCredSslServerTrust.CertFailures.NotYetValid) > 0)
            {
                Console.WriteLine(" - The certificate is not yet valid");
            }
            if ((failures & SvnAuthCredSslServerTrust.CertFailures.Expired) > 0)
            {
                Console.WriteLine(" - The certificate has expired");
            }
            if ((failures & SvnAuthCredSslServerTrust.CertFailures.Other) > 0)
            {
                Console.WriteLine(" - The certificate has an unknown error");
            }

            Console.WriteLine("Certificate informations:");
            Console.WriteLine("\tHostName:    " + certInfo.Hostname);
            Console.WriteLine("\tIssuer:      " + certInfo.IssuerDName);
            Console.WriteLine("\tValid From:  " + certInfo.ValidFrom);
            Console.WriteLine("\tValid Until: " + certInfo.ValidUntil);
            Console.WriteLine("\tFingerprint: " + certInfo.Fingerprint);

            cred = SvnAuthCredSslServerTrust.Alloc(pool);
            bool valid = false;

            while (!valid)
            {
                if (maySave)
                {
                    Console.WriteLine("(R)eject, accept (t)emporarily or accept (p)ermanently? ");
                }
                else
                {
                    Console.WriteLine("(R)eject or accept (t)emporarily? ");
                }

                string line = Console.ReadLine();
                if (line.Length > 0)
                {
                    char choice = line.ToLower()[0];
                    if (choice == 'r')
                    {
                        cred.AcceptedFailures = 0;
                        cred.MaySave          = false;
                        valid = true;
                    }
                    else if (choice == 't')
                    {
                        cred.AcceptedFailures = failures;
                        cred.MaySave          = false;
                        valid = true;
                    }
                    else if (choice == 'p')
                    {
                        cred.AcceptedFailures = failures;
                        cred.MaySave          = true;
                        valid = true;
                    }
                }
            }
            return(SvnError.NoError);
        }