Detecting Secure Sites using webbrowser.encryptionlevel-VBForums
Results 1 to 1 of 1

Thread: Detecting Secure Sites using webbrowser.encryptionlevel

  1. #1

    Thread Starter
    Frenzied Member jdc20181's Avatar
    Join Date
    Oct 2015
    Location
    Indiana
    Posts
    1,029

    Detecting Secure Sites using webbrowser.encryptionlevel

    Overview

    The code is converted from c# and is from a pretty old example but it still works, and does so wonderfully.

    I am covering how to do this with or without a tab control - I will explain everything to you the best I can (and willl update this further with more explainations)


    Pre - Setup (what you need to get started)
    Toolstrip
    Tabcontrol
    A couple buttons on toolstrip (need 2)
    Textbox on toolstrip


    Setup without a tab control
    ToolStrip
    Webbrowser control

    Setup

    Set up your form
    on toolstrip you need:
    a couple of buttons (2 at min)
    Textbox

    Setup with NO tab control
    When navigating simply add the done event handler to show if the website is secure (uses ssl) or not.

    Navigation:

    Code:
    webbrowser1.navigate(toolstriptextbox1.text)
     AddHandler brws.DocumentCompleted, AddressOf Done
    Done Event
    Code:
      Private Sub Done(ByVal sender As Object, ByVal e As Windows.Forms.WebBrowserDocumentCompletedEventArgs)     
            If CType(Tabcontrol1.SelectedTab.Controls.Item(0), WebBrowser).EncryptionLevel <> WebBrowserEncryptionLevel.Insecure Then
                SSL_Lock.Visible = True
            Else
                SSL_Lock.Visible = False
            End If
           
    
        End Sub

    setup with a tab control

    You are going to call new tabs (example shows when navigating any time a new instance occurs this occurs) with a button, add this code, and then the event handler will handle when to show the secure website button (it occurs if the website uses SSL)

    Navigation Event:


    Code:
     Try
                Dim brws As New WebBrowser
                brws.ScriptErrorsSuppressed = True
                AddHandler brws.DocumentCompleted, AddressOf Done
                int = int + 1
                CType(Tabcontrol1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(ToolStripTextBox1.Text)
            Catch ex As Exception
            End Try
    Done Event:

    Code:
      Private Sub Done(ByVal sender As Object, ByVal e As Windows.Forms.WebBrowserDocumentCompletedEventArgs)     
            If CType(Tabcontrol1.SelectedTab.Controls.Item(0), WebBrowser).EncryptionLevel <> WebBrowserEncryptionLevel.Insecure Then
                SSL_Lock.Visible = True
            Else
                SSL_Lock.Visible = False
            End If
           
    
        End Sub

    You can find documentation on this here

    The original code I adapted this from here

    Understand that the only part from the orignal example I used was checking to see if the site was secure or not.

    You can put a photo/icon of a lock on the button or use text.
    Last edited by jdc20181; Mar 19th, 2017 at 09:36 PM.
    Disclaimer: When code is given for example - it is merely a example. See my First CodeBank Submission Upgrading to the newest IE when using the Webbrowser control See my Second CodeBank SubmissionVB.NET - Recording History or changes using WebbrowserControl RichTextBox Textbox
    See my Third codebank submission VB.NET - Detecting Secure/Insecure Websites (ssl) w/ Webbrowser control See CodeBank Submission 4 A Simple Large View Calendar Control See my browser project BeffsBrowser Try my SpeedTest Project

    Unless said otherwise (e.g. From one of my projects thus, those are mostly licensed under MIT) - All Code snippets advice or otherwise that I post on this site, are expressly licensed under Creative Commons Attribution 4.0 International Please respect my copyrights.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.