473,396 Members | 1,814 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

exhausted all avenues

Does anyone know how to accept all certificates when a
site is browsed to through the axwebbrowser in a windows
application?

Thanks.
Nov 20 '05 #1
3 1613
Imports System
Imports System.IO
Imports System.Net
Imports System.Threading
Imports System.Text.RegularExpressions
Imports System.Text.Encoding
Imports System.Security.Cryptography.X509Certificates

Public Class TrustAllCertificatePolicy
Implements System.Net.ICertificatePolicy
Public Function CheckValidationResult(ByVal srvPoint As
System.Net.ServicePoint, ByVal certificate As
System.Security.Cryptography.X509Certificates.X509 Certificate, ByVal
request
As System.Net.WebRequest, ByVal certificateProblem As Integer) _
As Boolean Implements
System.Net.ICertificatePolicy.CheckValidationResul t
Return True
End Function
End Class
Private Sub cmdGet_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdGet.Click
'Create(a) 'WebRequest' object with the specified url
System.Net.ServicePointManager.CertificatePolicy = New
TrustAllCertificatePolicy

Dim myWebRequest As WebRequest
'myWebRequest.Credentials = myCert.TrustAllCertificatePolicy
myWebRequest =
WebRequest.Create("https://sentri.us.nortel.com:8443/SENTRI/home.jsp")

' Send the 'WebRequest' and wait for response.
Dim myWebResponse As WebResponse
myWebResponse = myWebRequest.GetResponse()
' Call method 'GetResponseStream' to obtain stream associated with
the response object
Dim ReceiveStream As Stream
ReceiveStream = myWebResponse.GetResponseStream()

Dim encode As System.Text.Encoding
encode = GetEncoding("utf-8")

' Pipe the stream to a higher level stream reader with the required
encoding format.
Dim readStream As New StreamReader(ReceiveStream, encode)
'txtLog.Text = (ControlChars.CrLf + "Response stream received")
Dim read(1024) As [Char]

' Read 256 charcters at a time .
Dim count As Integer = readStream.Read(read, 0, 1024)
txtLog.Text = ""
'While count > 0
While readStream.Peek >= 0

' Dump the 256 characters on a string and display the string
onto the console.
Dim str As New [String](read, 0, count)
txtLog.Text = txtLog.Text & (str)
count = readStream.Read(read, 0, 1024)

End While
Dim str2 As New [String](read, 0, count)
txtLog.Text = txtLog.Text & (str2)
count = readStream.Read(read, 0, 1024)
'Console.WriteLine("")

' Release the resources of stream object.
readStream.Close()

' Release the resources of response object.
myWebResponse.Close()

End Sub

"I'm spent" <an*******@discussions.microsoft.com> wrote in message
news:1d*****************************@phx.gbl:
Does anyone know how to accept all certificates when a
site is browsed to through the axwebbrowser in a windows
application?

Thanks.


Nov 20 '05 #2
Thanks for the reply.

I have a couple of questions?

1. What type is the txtLog variable (it's declaration is
not specified in the code)?

2. I know that reading from the response stream gives the
html that the browser renders as a webpage, but how do I
send it to the axwebbrowser?

The websites I am navigating to are ASP pages that have
controls on them that I need to be able to use once the
page is rendered in the axwebbrowser.

Thanks again!!

-----Original Message-----
Imports System
Imports System.IO
Imports System.Net
Imports System.Threading
Imports System.Text.RegularExpressions
Imports System.Text.Encoding
Imports System.Security.Cryptography.X509Certificates

Public Class TrustAllCertificatePolicy
Implements System.Net.ICertificatePolicy
Public Function CheckValidationResult(ByVal srvPoint As
System.Net.ServicePoint, ByVal certificate As
System.Security.Cryptography.X509Certificates.X50 9Certific ate, ByValrequest
As System.Net.WebRequest, ByVal certificateProblem As Integer) _As Boolean Implements
System.Net.ICertificatePolicy.CheckValidationResu lt
Return True
End Function
End Class
Private Sub cmdGet_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles cmdGet.Click
'Create(a) 'WebRequest' object with the specified url
System.Net.ServicePointManager.CertificatePolic y = New
TrustAllCertificatePolicy

Dim myWebRequest As WebRequest
'myWebRequest.Credentials = myCert.TrustAllCertificatePolicymyWebRequest =
WebRequest.Create ("https://sentri.us.nortel.com:8443/SENTRI/home.jsp")
' Send the 'WebRequest' and wait for response.
Dim myWebResponse As WebResponse
myWebResponse = myWebRequest.GetResponse()
' Call method 'GetResponseStream' to obtain stream associated withthe response object
Dim ReceiveStream As Stream
ReceiveStream = myWebResponse.GetResponseStream()

Dim encode As System.Text.Encoding
encode = GetEncoding("utf-8")

' Pipe the stream to a higher level stream reader with the requiredencoding format.
Dim readStream As New StreamReader(ReceiveStream, encode)
'txtLog.Text = (ControlChars.CrLf + "Response stream received")Dim read(1024) As [Char]

' Read 256 charcters at a time .
Dim count As Integer = readStream.Read(read, 0, 1024)
txtLog.Text = ""
'While count > 0
While readStream.Peek >= 0

' Dump the 256 characters on a string and display the stringonto the console.
Dim str As New [String](read, 0, count)
txtLog.Text = txtLog.Text & (str)
count = readStream.Read(read, 0, 1024)

End While
Dim str2 As New [String](read, 0, count)
txtLog.Text = txtLog.Text & (str2)
count = readStream.Read(read, 0, 1024)
'Console.WriteLine("")

' Release the resources of stream object.
readStream.Close()

' Release the resources of response object.
myWebResponse.Close()

End Sub

"I'm spent" <an*******@discussions.microsoft.com> wrote in messagenews:1d*****************************@phx.gbl:
Does anyone know how to accept all certificates when a
site is browsed to through the axwebbrowser in a windows
application?

Thanks.


.

Nov 20 '05 #3


1. What type is the txtLog variable (it's declaration is
not specified in the code)?
It appears to be a textbox or an object that has a text property of some
kind.

2. I know that reading from the response stream gives the
html that the browser renders as a webpage, but how do I
send it to the axwebbrowser?
I would look for a substring or indexof within the string and when found
lock on to it with a variable and send as you need to.


The websites I am navigating to are ASP pages that have
controls on them that I need to be able to use once the
page is rendered in the axwebbrowser.

Thanks again!!

-----Original Message-----
Imports System
Imports System.IO
Imports System.Net
Imports System.Threading
Imports System.Text.RegularExpressions
Imports System.Text.Encoding
Imports System.Security.Cryptography.X509Certificates

Public Class TrustAllCertificatePolicy
Implements System.Net.ICertificatePolicy
Public Function CheckValidationResult(ByVal srvPoint As
System.Net.ServicePoint, ByVal certificate As
System.Security.Cryptography.X509Certificates.X50 9Certific

ate, ByVal
request
As System.Net.WebRequest, ByVal certificateProblem As

Integer) _
As Boolean Implements
System.Net.ICertificatePolicy.CheckValidationResu lt
Return True
End Function
End Class
Private Sub cmdGet_Click(ByVal sender As System.Object,

ByVal e As
System.EventArgs) Handles cmdGet.Click
'Create(a) 'WebRequest' object with the specified url
System.Net.ServicePointManager.CertificatePolic y = New
TrustAllCertificatePolicy

Dim myWebRequest As WebRequest
'myWebRequest.Credentials =

myCert.TrustAllCertificatePolicy
myWebRequest =
WebRequest.Create

("https://sentri.us.nortel.com:8443/SENTRI/home.jsp")

' Send the 'WebRequest' and wait for response.
Dim myWebResponse As WebResponse
myWebResponse = myWebRequest.GetResponse()
' Call method 'GetResponseStream' to obtain stream

associated with
the response object
Dim ReceiveStream As Stream
ReceiveStream = myWebResponse.GetResponseStream()

Dim encode As System.Text.Encoding
encode = GetEncoding("utf-8")

' Pipe the stream to a higher level stream reader with

the required
encoding format.
Dim readStream As New StreamReader(ReceiveStream, encode)
'txtLog.Text = (ControlChars.CrLf + "Response stream

received")
Dim read(1024) As [Char]

' Read 256 charcters at a time .
Dim count As Integer = readStream.Read(read, 0, 1024)
txtLog.Text = ""
'While count > 0
While readStream.Peek >= 0

' Dump the 256 characters on a string and display the

string
onto the console.
Dim str As New [String](read, 0, count)
txtLog.Text = txtLog.Text & (str)
count = readStream.Read(read, 0, 1024)

End While
Dim str2 As New [String](read, 0, count)
txtLog.Text = txtLog.Text & (str2)
count = readStream.Read(read, 0, 1024)
'Console.WriteLine("")

' Release the resources of stream object.
readStream.Close()

' Release the resources of response object.
myWebResponse.Close()

End Sub

"I'm spent" <an*******@discussions.microsoft.com> wrote

in message
news:1d*****************************@phx.gbl:
Does anyone know how to accept all certificates when a
site is browsed to through the axwebbrowser in a windows
application?

Thanks.


.


Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Paul | last post by:
Hi, I'm using TikiWiki and was using its file upload feature, trying to upload a 2MB file. I get this error: Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate...
2
by: Phil Powell | last post by:
Actually the client is saying it sometimes happens and sometimes doesn't happen, and when they refresh their screen it clears itself (I assume the memory clears). Here is line 1135: $result =...
0
by: Joe | last post by:
Hi, Now I am using Red Hat Linux 8.0 + squirrelmail as mail server. One day, I got the following warning: Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 35...
3
by: Ron Eggler | last post by:
Hi, I'm trying to resize a pic with the Code pasted below and get following Error, why, how to resize it correctly??? src:...
3
by: Dave Smithz | last post by:
Hi there, I changed one of my MySQL search queries to allow a situation where the user gets much more information returned. However, it has now given me the error message: Fatal error: Allowed...
5
by: Aaron Birkland | last post by:
I have a long but straightforward query (on some very large tables) that always ends in 'Memory exhausted in AllocSetAlloc(108)'. Even stranger are some messages that appear in the logfile, such...
1
by: | last post by:
I have a table with about 1,400,000 rows in it. Each DELETE cascades to about 7 tables. When I do a 'DELETE FROM events' I get the following error: ERROR: Memory exhausted in...
0
by: Mattia | last post by:
************************************************** Manage image without exhausted memory ************************************************** Hi; I have a big problem. I must create a script that...
7
by: jonathan.dyer | last post by:
here is the problem write a function tht uses a switch statement to determine the number of the nearest cross street for a given address and avenue number according to the preceding algorithm....
3
by: jitendrarathod | last post by:
Hello, I have a one PHP script which crawled the URLs and get the job from the URLs. My logic is so simple. First take the URL from database(total 25000 URLs). Then start to crawl the URLs....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.