0

I'm at a loss here. I have created an API for a website of mine (If it's of any value, this is being locally hosted for easier development). I am trying to pass it some info via a simple GET request, but I'm running into a big problem.

Dim wc As WebClient = New WebClient()
Dim ServerResponse As String = wc.DownloadString(New Uri(entireRequest))
MsgBox("This will NEVER be run")

The above code is being run in a separate thread. The problem is that when the DownloadString line is called, no other code afterwards is ever run. I have tried setting breakpoints after that line and none are hit.

A Try...Catch block does nothing. I have tried catching Net.WebExceptions and System.Exceptions. Nothing's ever caught. My breakpoint on End Try is never hit..

I have noticed that this will only happen if entireRequest is an https connection. This problem doesn't happen if it's not encrypted.

Adding the following in order to ignore the self-signed cert does nothing:

Public Class clsSSL
    Public Shared Function AcceptAllCertifications(ByVal sender As Object, ByVal certification As System.Security.Cryptography.X509Certificates.X509Certificate, ByVal chain As System.Security.Cryptography.X509Certificates.X509Chain, ByVal sslPolicyErrors As System.Net.Security.SslPolicyErrors) As Boolean
        Return True
    End Function
End Class

Thanks in advance! I've done a lot of searching and you're my last hope!

Andrew Paglusch
  • 767
  • 1
  • 7
  • 17

1 Answers1

0

Problem solved thanks to this thread: Requesting html over https with c# Webclient

I just needed to add the following:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3

I'm still confused as to why I wasn't being presented with any exceptions. Any answers on that?

Community
  • 1
  • 1
Andrew Paglusch
  • 767
  • 1
  • 7
  • 17
  • 1
    I could only guess as to the reasoning and if thought about logically it was literally just stuck there. Similar to an infinite loop but with a single line instead of multiple ones. It possibly could have just kept trying to process that line and just failed and crash because of it. – Richard Paulicelli May 12 '14 at 21:58
  • 1
    You're probably correct. DownloadString is a blocking method, so it was probably just hung indefinitely. It's surprising that there is no built-in timeout or failsafe. – Andrew Paglusch May 13 '14 at 14:16