示例#1
0
        public override void AssignSession(Session oS)
        {
            Clear();
            if (oS.isHTTPS || (oS.BitFlags & SessionFlags.IsDecryptingTunnel) == SessionFlags.IsDecryptingTunnel)
            {
                Tuple <X509Chain, X509Certificate2> cert;
                if (CertificateInspector.ServerCertificates.TryGetValue(Tuple.Create(oS.hostname, oS.port), out cert))
                {
                    var pkp           = oS.ResponseHeaders.Exists("public-key-pins") ? oS.ResponseHeaders["public-key-pins"] : null;
                    var pkpReportOnly = oS.ResponseHeaders.Exists("public-key-pins-report-only") ? oS.ResponseHeaders["public-key-pins-report-only"] : null;
                    var pinnedKeys    = pkp == null && pkpReportOnly == null ? null : PublicKeyPinsParser.Parse(pkp ?? pkpReportOnly);
                    var reportOnly    = pkpReportOnly != null;
                    var chain         = cert.Item1;

                    var control = new WpfCertificateControl();
                    control.DataContext = new HttpSecurityModel
                    {
                        IsNotTunnel      = (oS.BitFlags & SessionFlags.IsDecryptingTunnel) != SessionFlags.IsDecryptingTunnel,
                        CertificateChain = new AsyncProperty <ObservableCollection <CertificateModel> >(Task.Factory.StartNew(() =>
                        {
                            var chainItems = chain.ChainElements.Cast <X509ChainElement>().Select((t, i) => AssignCertificate(t, reportOnly, pinnedKeys, chain, i)).ToList();
                            return(new ObservableCollection <CertificateModel>(chainItems));
                        })),
                        Hpkp = new HpkpModel
                        {
                            HasHpkpHeaders = pinnedKeys != null,
                            RawHpkpHeader  = pkp ?? pkpReportOnly,
                            PinDirectives  =
                                pinnedKeys == null ? null
                                : new ObservableCollection <HpkpHashModel>(pinnedKeys.PinnedKeys.Select(pk => new HpkpHashModel {
                                Algorithm = pk.Algorithm, HashBase64 = pk.FingerprintBase64
                            }).ToArray())
                        }
                    };
                    _panel.Children.Add(control);
                }
            }
            else
            {
                _panel.Children.Add(new System.Windows.Controls.Label {
                    Content = "Certificates are for HTTPS connections only."
                });
            }
        }
示例#2
0
        public override void AssignSession(Session oS)
        {
            Clear();
            if (!CertificateInspector.HttpsDecryptionEnabledOnStartup || !CONFIG.bCaptureCONNECT || !CONFIG.bMITM_HTTPS)
            {
                _panel.Children.Add(new System.Windows.Controls.Label {
                    Content = "Fiddler Cert Inspector requires enabling decryption of HTTPS traffic, and restarting Fiddler."
                });
                return;
            }
            if (!CertificateInspector.IsSupportedOperatingSystem)
            {
                _panel.Children.Add(new System.Windows.Controls.Label
                {
                    Content = "Fiddler Cert Inspector requires Windows Vista or Windows Server 2008 or later."
                });
                return;
            }
            var control     = new WpfCertificateControl();
            var masterModel = new CertInspectorModel();

            masterModel.UpdateBarModel                = new UpdateBarModel(CertificateInspector.LatestVersion?.Item1, CertificateInspector.LatestVersion?.Item2);
            masterModel.AskUpdateBarModel             = _askUpdateBarModel;
            masterModel.AskUpdateBarModel.AskRequired = !FiddlerApplication.Prefs.GetBoolPref(PreferenceNames.ASK_CHECK_FOR_UPDATES_PREF, false);
            masterModel.SettingsCommand               = new RelayCommand(_ =>
            {
                var window   = new SettingsWindow();
                var helper   = new WindowInteropHelper(window);
                helper.Owner = FiddlerApplication.UI.Handle;
                window.ShowDialog();
            });
            masterModel.HttpSecurityModel = new HttpSecurityModel
            {
                IsNotTunnel  = (oS.BitFlags & SessionFlags.IsDecryptingTunnel) != SessionFlags.IsDecryptingTunnel,
                ContentChain = new AsyncProperty <ObservableCollection <CertificateModel> >(Task.Factory.StartNew(() =>
                {
                    if (!oS.bHasResponse)
                    {
                        return(null);
                    }
                    var contentChain = ChainForContent(oS.ResponseBody);
                    if (contentChain == null)
                    {
                        return(null);
                    }
                    var chainItems = contentChain.ChainElements.Cast <X509ChainElement>().Select((t, i) => AssignCertificate(t, false, null, contentChain, i)).ToList();
                    return(new ObservableCollection <CertificateModel>(chainItems));
                }))
            };
            if (oS.isHTTPS || (oS.BitFlags & SessionFlags.IsDecryptingTunnel) == SessionFlags.IsDecryptingTunnel)
            {
                Tuple <X509Chain, X509Certificate2> cert;
                if (CertificateInspector.ServerCertificates.TryGetValue(Tuple.Create(oS.hostname, oS.port), out cert))
                {
                    var pkp           = oS.ResponseHeaders.Exists("public-key-pins") ? oS.ResponseHeaders["public-key-pins"] : null;
                    var pkpReportOnly = oS.ResponseHeaders.Exists("public-key-pins-report-only") ? oS.ResponseHeaders["public-key-pins-report-only"] : null;
                    var pinnedKeys    = pkp == null && pkpReportOnly == null ? null : PublicKeyPinsParser.Parse(pkp ?? pkpReportOnly);
                    var reportOnly    = pkpReportOnly != null;
                    var chain         = cert.Item1;
                    masterModel.HttpSecurityModel.CertificateChain = new AsyncProperty <ObservableCollection <CertificateModel> >(Task.Factory.StartNew(() =>
                    {
                        var chainItems = chain.ChainElements.Cast <X509ChainElement>().Select((t, i) => AssignCertificate(t, reportOnly, pinnedKeys, chain, i)).ToList();
                        return(new ObservableCollection <CertificateModel>(chainItems));
                    }));
                    masterModel.HttpSecurityModel.Hpkp = new HpkpModel
                    {
                        HasHpkpHeaders = pinnedKeys != null,
                        RawHpkpHeader  = pkp ?? pkpReportOnly,
                        PinDirectives  =
                            pinnedKeys == null ? null
                            : new ObservableCollection <HpkpHashModel>(pinnedKeys.PinnedKeys.Select(pk => new HpkpHashModel {
                            Algorithm = pk.Algorithm, HashBase64 = pk.FingerprintBase64
                        }).ToArray())
                    };
                }
            }
            control.DataContext = masterModel;
            _panel.Children.Add(control);
        }