Ejemplo n.º 1
0
 private void ShowCertDialog()
 {
     Logger.Debug("Showing Cert Dialog: " + Handler.UserMessage);
     CertPolicyHandler.Response ret = CertPolicyHandler.Response.None;
     using (var handle = new AutoResetEvent(false)) {
         Application.Invoke(delegate {
             try {
                 using (MessageDialog md = new MessageDialog(null, DialogFlags.Modal,
                                                             MessageType.Warning, ButtonsType.None, Handler.UserMessage +
                                                             "\n\nDo you trust this certificate?")
                 {
                     Title = "Untrusted Certificate"
                 })
                 {
                     using (var noButton = md.AddButton("No", (int)CertPolicyHandler.Response.CertDeny))
                         using (var justNowButton = md.AddButton("Just now", (int)CertPolicyHandler.Response.CertAcceptSession))
                             using (var alwaysButton = md.AddButton("Always", (int)CertPolicyHandler.Response.CertAcceptAlways))
                             {
                                 ret = (CertPolicyHandler.Response)md.Run();
                                 md.Destroy();
                             }
                 }
             } finally {
                 handle.Set();
             }
         }
                            );
         handle.WaitOne();
     }
     Logger.Debug("Cert Dialog return:" + ret.ToString());
     Handler.UserResponse = ret;
 }
Ejemplo n.º 2
0
        private void ShowCertDialog()
        {
            Logger.Debug("Showing Cert Dialog: " + Handler.UserMessage);
            CertPolicyHandler.Response ret = CertPolicyHandler.Response.None;
            var r = MessageBox.Show(Handler.UserMessage +
                                    "\n\n" + Properties_Resources.DoYouTrustTheCertificate,
                                    Properties_Resources.UntrustedCertificate, MessageBoxButton.YesNoCancel, MessageBoxImage.Warning);

            switch (r)
            {
            case MessageBoxResult.Yes:
                ret = CertPolicyHandler.Response.CertAcceptAlways;
                break;

            case MessageBoxResult.No:
                ret = CertPolicyHandler.Response.CertDeny;
                break;

            case MessageBoxResult.Cancel:
                ret = CertPolicyHandler.Response.CertAcceptSession;
                break;
            }
            Logger.Debug("Cert Dialog return:" + ret.ToString());
            Handler.UserResponse = ret;
        }
Ejemplo n.º 3
0
        private void ShowCertDialog()
        {
            Logger.Debug("Showing Cert Dialog: " + Handler.UserMessage);
            CertPolicyHandler.Response ret = CertPolicyHandler.Response.None;
            using (var signal = new AutoResetEvent(false))
            {
                InvokeOnMainThread(delegate
                {
                    try
                    {
                        NSAlert alert = NSAlert.WithMessage("Untrusted Certificate", "No", "Always", "Just now", Handler.UserMessage + "\n\nDo you trust this certificate?");
                        switch (alert.RunModal())
                        {
                        case 1:
                            ret = CertPolicyHandler.Response.CertDeny;
                            break;

                        case 0:
                            ret = CertPolicyHandler.Response.CertAcceptAlways;
                            break;

                        case -1:
                            ret = CertPolicyHandler.Response.CertAcceptSession;
                            break;

                        default:
                            ret = CertPolicyHandler.Response.None;
                            break;
                        }
                    }
                    catch (Exception)
                    {
                        ret = CertPolicyHandler.Response.None;
                    }
                    finally
                    {
                        signal.Set();
                    }
                });
                signal.WaitOne();
            }
            Logger.Debug("Cert Dialog return:" + ret.ToString());
            Handler.UserResponse = ret;
        }