Home All Groups Group Topic Archive Search About

HTTPS And VB.Net Apps

Author
18 Aug 2006 7:18 PM
tomb
Saeid Bagheri asked a very good question, and I've seen this question
here before but I have never seen it answered.  Can VB.Net desktop apps
utilize https?  If so, how?

Tom

Author
18 Aug 2006 10:10 PM
Mudhead
Free:    http://www.mentalis.org/soft/projects/ssocket/
Buy component:     http://www.dart.com/powertcp/secure_environments.asp
Specifications:    http://wp.netscape.com/eng/ssl3/draft302.txt

Show quoteHide quote
"tomb" <t***@technetcenter.com> wrote in message
news:AmoFg.21628$q96.11432@bignews4.bellsouth.net...
> Saeid Bagheri asked a very good question, and I've seen this question here
> before but I have never seen it answered.  Can VB.Net desktop apps utilize
> https?  If so, how?
>
> Tom
Author
19 Aug 2006 5:16 AM
gene kelley
On Fri, 18 Aug 2006 15:18:00 -0400, tomb <t***@technetcenter.com> wrote:

>Saeid Bagheri asked a very good question, and I've seen this question
>here before but I have never seen it answered.  Can VB.Net desktop apps
>utilize https?  If so, how?
>
>Tom

I asked about this myself some weeks ago in the context of simply wanting to download selected files
with HTTPS urls using WebClient.  The current Help file talks about how to do this, but leads to an
example that returns a warning/error that the method is obsolete.  The current Help file (nor MSDN)
had any example on how to use the suggested replacement method.

For my particular needs, I eventually wound up with this relatively simple method:

Imports System.Net.Security
Imports System.Security.Crytopgaphy.X509Certificates

Try
ServicePointManager.ServerCertificateValidationCallback = New _
RemoteCertificateValidationCallback(AddressOf ValidateCertificate)

WebClient1.DownloadDataAsync(uri)

Catch


End Try

    Private Function ValidateCertificate(ByVal sender As Object, _
        ByVal certificate As X509Certificate, ByVal chain As X509Chain, _
        ByVal sslPolicyErrors As SslPolicyErrors) As Boolean

        'Return True to force the certificate to be accepted.
        Return True
    End Function

In the above snippet, when the URI contains HTTPS, the certificate is accepted (the user ceritficate
dialog is not displayed) and the download preceeds.  This works for my specific need in this case,
but others may want user intereaction with the certificate dialog. 

Gene
Author
19 Aug 2006 1:36 PM
tomb
EXCELLENT!!!

T

gene kelley wrote:

Show quoteHide quote
>On Fri, 18 Aug 2006 15:18:00 -0400, tomb <t***@technetcenter.com> wrote:
>

>
>>Saeid Bagheri asked a very good question, and I've seen this question
>>here before but I have never seen it answered.  Can VB.Net desktop apps
>>utilize https?  If so, how?
>>
>>Tom
>>   
>>
>
>I asked about this myself some weeks ago in the context of simply wanting to download selected files
>with HTTPS urls using WebClient.  The current Help file talks about how to do this, but leads to an
>example that returns a warning/error that the method is obsolete.  The current Help file (nor MSDN)
>had any example on how to use the suggested replacement method.
>
>For my particular needs, I eventually wound up with this relatively simple method:
>
>Imports System.Net.Security
>Imports System.Security.Crytopgaphy.X509Certificates
>
>Try
>ServicePointManager.ServerCertificateValidationCallback = New _
>RemoteCertificateValidationCallback(AddressOf ValidateCertificate)
>
>WebClient1.DownloadDataAsync(uri)
>
>Catch
>
>
>End Try
>
>    Private Function ValidateCertificate(ByVal sender As Object, _
>        ByVal certificate As X509Certificate, ByVal chain As X509Chain, _
>        ByVal sslPolicyErrors As SslPolicyErrors) As Boolean
>      
>        'Return True to force the certificate to be accepted.
>        Return True
>    End Function
>
>In the above snippet, when the URI contains HTTPS, the certificate is accepted (the user ceritficate
>dialog is not displayed) and the download preceeds.  This works for my specific need in this case,
>but others may want user intereaction with the certificate dialog. 
>
>Gene

>