Downloading file with HTTPSecureSocket not successful

Hi all!

I have many links that I extracted by a source code.
When I paste one of this in a normal browser. like Mozilla, Safari, Opera. It redirects me to the Login Page of that website, Once identificated correctly with credentials (ID and Password) then proceed to download the requested file. And It works without a problem.

So, I tried to download with a HTTPSocket but I get nothing. Then I thought it requires a Secure connection. And In fact requires an HTTPSecureSocket.

  1. I created a TCPSocket on the IDE and renamed the Superclass to “HTTPSecureSocket”

  2. On its AutenticationRequired event, I specified User and Password, like this:
    Name = “MCE0708241W5”
    Password = “Mg707080”
    Return True

  3. In the Button that I’m Trying to download the file I have this, and assigned these parameters to the socket:

Name = “HEREMYUSER”
Password = “HEREMYPASSWORD”
Return True

Dim f as FolderItem = SpecialFolder.Documents.Child(“CFDieBrain”).Child(“Recibidas”).Child(“factura.xml”)

Dim link As String = “https://portalcfdi.facturaelectronica.sat.gob.mx/RecuperaCfdi.aspx?Datos=kQOsJGVwD8sDoZrJpUP+LK9Wg536uW1c240WA2zvRSwMK+egLlALYuuyqVIoiLU++2NA1gly5lJ3hnwrS0DFD9YxM3LtOWQmxXOWnZrTPg8tn0kfkpUTJgUi0N0TxiQQlSnnkt2W5P5smEIIhIqJGoY9qlbnBrlgfDwY1yj3tqDQpKHBnF//MT0ClKNKj2Iu89e4ZT3s2oYbhK87xMKUQ7sUjekMRTnnEEFcBF79iXNpZvJdY696EjGi2+e1b6HUDFrdtQWlvx7zeEF4PiU0vcW5sn4Hrt8iDGUvf43UXtFKIyXNcBycnwn0dtmf4fsxvK+4HGBuTbLTHIOc3eWjaZrKcQ1wtAX17siauLICXxpWTifGNVUKpRKrmWoYmEeNUgojqDnn4/cxYVitWHoZ69LdjQroNmkpmCYXW8pTLsl/OG2oSXR8rtRwMmm2mmAyOSo8FQDhABwm/vSXZT+nA2KBU8JlZ5ZaMs8R6loDzxU=

downloadSocket.Secure = True
downloadSocket.Port = 443
downloadSocket.ConnectionType = 3

downloadSocket.SetRequestHeader(“Authorization”, "Basic " + EncodeBase64(“HEREMYUSER” + “:” + “HEREMYPASSWORD”))
if downloadSocket.Get(enlace, f, 30) = True then
MsgBox(“Download complete”)
end if.

But instead of get download the XML File as normal, I got a blank page with this legend: “Object Moved” with a link to another site.
And when I clic this link. I got an error:

An error occurred while processing your request.

HTTP Error Code: 400
Message: ACS20012: The request is not a valid WS-Federation protocol message.

Any Ideas?
Thanks

Google Docs ?