Added: ignore ssl option

This commit is contained in:
Ray 2021-10-12 19:55:00 +01:00
parent 60f199b0f2
commit 00f58d8259
7 changed files with 80 additions and 36 deletions

View File

@ -1,5 +1,6 @@
using BookmarkManager;
using bzit.bomg.Models;
using FizzyLauncher.Models;
using RyzStudio.Windows.Forms;
using RyzStudio.Windows.ThemedForms;
using System;
@ -34,12 +35,15 @@ namespace FizzyLauncher
protected WebParser webParser = null;
protected WebClient webClient = null;
protected bool isBusy = false;
protected AppSession appSession = null;
public BookmarkForm(BookmarkItem model, Image icon) : base()
public BookmarkForm(AppSession session, BookmarkItem model, Image icon) : base()
{
InitializeComponent();
appSession = session;
textBox1.Text = model.SiteName?.Trim() ?? string.Empty;
textBox2.Text = model.SiteAddress?.Trim() ?? string.Empty;
memoBox1.Text = model.SiteDescription?.Trim() ?? string.Empty;
@ -371,7 +375,7 @@ namespace FizzyLauncher
return;
}
BookmarkResult rs = webParser.RetrieveDetails(textBox2.Text);
BookmarkResult rs = webParser.RetrieveDetails(textBox2.Text, appSession.IgnoreSSL);
if (rs == null)
{
IsBusy = false;

View File

@ -487,7 +487,7 @@ namespace FizzyLauncher
return;
}
if (updateIconsForm == null) updateIconsForm = new UpdateIconsForm(treeView1, iconDatabase);
if (updateIconsForm == null) updateIconsForm = new UpdateIconsForm(this.CurrentSession, treeView1, iconDatabase);
updateIconsForm.ShowDialog();
}
@ -1201,14 +1201,7 @@ namespace FizzyLauncher
icon = iconDatabase.FindIcon(iconID);
//if (!string.IsNullOrWhiteSpace(model.SiteAddress))
//{
// string iconID = model?.ToHash();
// icon = iconDatabase.FindIcon(iconID);
//}
BookmarkForm bookmarkForm = new BookmarkForm(model, icon);
BookmarkForm bookmarkForm = new BookmarkForm(this.CurrentSession, model, icon);
if (bookmarkForm.ShowDialog() == DialogResult.OK)
{
//string iconID = bookmarkForm.Model.Item?.ToHash();

View File

@ -18,5 +18,7 @@
public string RunCommand { get; set; } = "{0}";
public bool IgnoreSSL { get; set; } = false;
}
}

View File

@ -14,9 +14,9 @@ namespace BookmarkManager
protected WebClient webClient2 = null;
public BookmarkResult RetrieveDetails(string url)
public BookmarkResult RetrieveDetails(string url, bool ignoreSSL)
{
string sourceCode = retrieveSourceCode(url);
string sourceCode = retrieveSourceCode(url, ignoreSSL);
if (string.IsNullOrWhiteSpace(sourceCode))
{
return null;
@ -77,9 +77,10 @@ namespace BookmarkManager
}
protected string retrieveSourceCode(string url)
protected string retrieveSourceCode(string url, bool ignoreSSL)
{
if (webClient == null) webClient = new HttpWeb();
webClient.IgnoreSSL = ignoreSSL;
string sourceCode;

View File

@ -19,8 +19,8 @@ namespace FizzyLauncher
private RyzStudio.Windows.Forms.THorizontalSeparator tHorizontalSeparator3;
private TTextBox textBox1;
private RyzStudio.Windows.Forms.THorizontalSeparator tHorizontalSeparator2;
private TYesNoPickerBox pickerBox4;
private Label label2;
protected MainForm parentForm = null;
@ -54,6 +54,8 @@ namespace FizzyLauncher
this.tHorizontalSeparator2 = new RyzStudio.Windows.Forms.THorizontalSeparator();
this.tHorizontalSeparator3 = new RyzStudio.Windows.Forms.THorizontalSeparator();
this.textBox1 = new RyzStudio.Windows.ThemedForms.TTextBox();
this.pickerBox4 = new RyzStudio.Windows.ThemedForms.TYesNoPickerBox();
this.label2 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
@ -233,11 +235,41 @@ namespace FizzyLauncher
this.textBox1.TabIndex = 192;
this.textBox1.UseSystemPasswordChar = false;
//
// pickerBox4
//
this.pickerBox4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.pickerBox4.BackColor = System.Drawing.Color.Transparent;
this.pickerBox4.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.pickerBox4.Location = new System.Drawing.Point(285, 237);
this.pickerBox4.Margin = new System.Windows.Forms.Padding(10, 4, 10, 4);
this.pickerBox4.Name = "pickerBox4";
this.pickerBox4.Padding = new System.Windows.Forms.Padding(10, 6, 7, 5);
this.pickerBox4.Size = new System.Drawing.Size(84, 34);
this.pickerBox4.SubmitButton = null;
this.pickerBox4.TabIndex = 194;
this.pickerBox4.Value = true;
//
// label2
//
this.label2.AutoSize = true;
this.label2.BackColor = System.Drawing.Color.Transparent;
this.label2.ForeColor = System.Drawing.SystemColors.ControlText;
this.label2.Location = new System.Drawing.Point(10, 237);
this.label2.Margin = new System.Windows.Forms.Padding(0);
this.label2.Name = "label2";
this.label2.Padding = new System.Windows.Forms.Padding(0, 9, 0, 10);
this.label2.Size = new System.Drawing.Size(95, 34);
this.label2.TabIndex = 193;
this.label2.Text = "Ignore SSL Errors";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// OptionsForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(384, 521);
this.Controls.Add(this.pickerBox4);
this.Controls.Add(this.label2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.tHorizontalSeparator3);
this.Controls.Add(this.tHorizontalSeparator2);
@ -278,6 +310,7 @@ namespace FizzyLauncher
pickerBox1.Value = parentForm.CurrentSession.EnableAutoPosition;
pickerBox2.Value = parentForm.CurrentSession.AlwaysOnTop;
textBox1.Text = parentForm.CurrentSession.RunCommand ?? string.Empty;
pickerBox4.Value = parentForm.CurrentSession.IgnoreSSL;
}
private void button1_MouseClick(object sender, MouseEventArgs e)
@ -290,6 +323,7 @@ namespace FizzyLauncher
parentForm.CurrentSession.EnableAutoPosition = pickerBox1.Value;
parentForm.CurrentSession.AlwaysOnTop = pickerBox2.Value;
parentForm.CurrentSession.RunCommand = textBox1.Text?.Trim();
parentForm.CurrentSession.IgnoreSSL = pickerBox4.Value;
}
this.DialogResult = DialogResult.OK;

View File

@ -8,35 +8,41 @@ namespace RyzStudio.Net
{
public class HttpWeb
{
public string defaultUserAgent = "Momozilla/5.0 (" + Environment.OSVersion.Platform.ToString() + " ; " + Environment.OSVersion.VersionString + "; " + Application.CurrentCulture.TwoLetterISOLanguageName + ")";
public int defaultTimeout = 6000;
public int defaultMaxRedirect = 8;
public bool defaultAllowRedirect = true;
public CookieContainer defaultCookierContainer = null;
public HttpWeb()
{
}
public HttpWebRequest CreateRequest(string url)
{
return this.CreateRequest(url, url);
}
public string UserAgent { get; set; } = "Momozilla/5.0 (" + Environment.OSVersion.Platform.ToString() + " ; " + Environment.OSVersion.VersionString + "; " + Application.CurrentCulture.TwoLetterISOLanguageName + ")";
public int Timeout { get; set; } = 6000;
public int MaxRedirect { get; set; } = 8;
public bool AllowRedirect { get; set; } = true;
public bool IgnoreSSL { get; set; } = false;
public CookieContainer CookierJar { get; set; } = null;
public HttpWebRequest CreateRequest(string url) => this.CreateRequest(url, url);
public HttpWebRequest CreateRequest(string url, string referrerURL)
{
if (defaultCookierContainer == null)
{
defaultCookierContainer = new CookieContainer();
}
if (this.CookierJar == null) this.CookierJar = new CookieContainer();
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
webRequest.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.NoCacheNoStore);
webRequest.MaximumAutomaticRedirections = defaultMaxRedirect;
webRequest.CookieContainer = defaultCookierContainer;
webRequest.UserAgent = defaultUserAgent;
webRequest.AllowAutoRedirect = defaultAllowRedirect;
webRequest.Timeout = defaultTimeout;
webRequest.MaximumAutomaticRedirections = this.MaxRedirect;
webRequest.CookieContainer = this.CookierJar;
webRequest.UserAgent = this.UserAgent;
webRequest.AllowAutoRedirect = this.AllowRedirect;
webRequest.Timeout = this.Timeout;
if (this.IgnoreSSL) webRequest.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;
return webRequest;
}
@ -164,5 +170,6 @@ namespace RyzStudio.Net
return rv;
}
}
}

View File

@ -1,5 +1,6 @@
using BookmarkManager;
using bzit.bomg.Models;
using FizzyLauncher.Models;
using RyzStudio.Windows.Forms;
using RyzStudio.Windows.ThemedForms;
using System;
@ -27,6 +28,7 @@ namespace FizzyLauncher
protected BookmarkTreeView bookmarkTreeView = null;
protected IconDatabase iconDatabase = null;
protected AppSession appSession = null;
protected WebParser webParser = null;
protected WebClient webClient = null;
@ -39,12 +41,13 @@ namespace FizzyLauncher
protected bool requestCancellation = false;
public UpdateIconsForm(BookmarkTreeView treeView, IconDatabase database)
public UpdateIconsForm(AppSession session, BookmarkTreeView treeView, IconDatabase database)
{
InitializeComponent();
bookmarkTreeView = treeView;
iconDatabase = database;
appSession = session;
pickerBox1.InnerControl.SelectedIndexChanged += comboBox1_SelectedIndexChanged;
@ -314,7 +317,7 @@ namespace FizzyLauncher
BookmarkItem item = bookmarkList[i];
BookmarkResult result = webParser.RetrieveDetails(item.SiteAddress);
BookmarkResult result = webParser.RetrieveDetails(item.SiteAddress, appSession.IgnoreSSL);
if (result == null)
{
continue;