Example #1
0
        static unsafe /*svn_error_t*/ IntPtr _svn_auth_ssl_server_trust_prompt_func(
            /*out svn_auth_cred_ssl_server_trust_t*/ void **ppCred, IntPtr baton, sbyte *realm, uint failures, /*svn_auth_ssl_server_cert_info_t*/ IntPtr certInfo, int maySave, /*apr_pool_t*/ IntPtr pool)
        {
            var wrapper = AprBaton <SvnAuthWrapper <SvnSslServerTrustEventArgs> > .Get(baton);

            var certInfoT = svn_auth_ssl_server_cert_info_t.__CreateInstance(certInfo);

            var args = new SvnSslServerTrustEventArgs(
                (SvnCertificateTrustFailures)failures,
                SvnBase.Utf8_PtrToString(certInfoT.hostname),
                SvnBase.Utf8_PtrToString(certInfoT.fingerprint),
                SvnBase.Utf8_PtrToString(certInfoT.valid_from),
                SvnBase.Utf8_PtrToString(certInfoT.valid_until),
                SvnBase.Utf8_PtrToString(certInfoT.issuer_dname),
                SvnBase.Utf8_PtrToString(certInfoT.ascii_cert),
                SvnBase.Utf8_PtrToString(realm), maySave != 0);

            var cred = (svn_auth_cred_ssl_server_trust_t.__Internal * *)ppCred;

            using (var tmpPool = new AprPool(pool, false))
            {
                *cred = null;
                try
                {
                    wrapper.Raise(args);
                }
                catch (Exception e)
                {
                    return(SvnException.CreateExceptionSvnError("Authorization handler", e).__Instance);
                }

                if (args.Cancel)
                {
                    return(svn_error.svn_error_create((int)SvnErrorCode.SVN_ERR_CANCELLED, null, "Authorization canceled operation").__Instance);
                }
                if (args.Break)
                {
                    return(IntPtr.Zero);
                }

                if (args.AcceptedFailures != SvnCertificateTrustFailures.None)
                {
                    *cred = (svn_auth_cred_ssl_server_trust_t.__Internal *)tmpPool.AllocCleared(
                        sizeof(svn_auth_cred_ssl_server_trust_t.__Internal));

                    (*cred)->accepted_failures = (uint)args.AcceptedFailures;
                    (*cred)->may_save          = args.Save ? 1 : 0;
                }
            }

            return(IntPtr.Zero);
        }
Example #2
0
 static void ImpSubversionWindowsSslServerTrustHandler(object sender, SvnSslServerTrustEventArgs e) => e.Break = true;