VS 2008 downloading from https and not http-VBForums
Results 1 to 18 of 18

Thread: downloading from https and not http

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2004
    Location
    India
    Posts
    453

    Question downloading from https and not http

    Hello Everyone,

    Currently my program used the following 2 ways to download file from my website

    1) My.computer.network.downloadfile("http://www.example.com/abcd.txt","abcd.txt","username","password")

    2) the second option is web client

    Now I may enable SSL in my site. In such a case will the above system work or I need to change code. Will http in url work or i need to change it to https.

    Similarly I read data from php script using webclient such as

    Code:
     Dim web_client As Net.WebClient = New Net.WebClient, Info As String = ""
            Dim response As IO.Stream = web_client.OpenRead("http://www.example.com/datetime.php")
    
            ' Read the result.
            Dim stream_reader As New IO.StreamReader(response)
            Info = stream_reader.ReadToEnd()
            ' Close the stream reader and its underlying stream.
            stream_reader.Close()
            response.Close()
    Will it work or I need to make changes. I am using VB.NET 2008.

    Regards,
    GR

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    31,336

    Re: downloading from https and not http

    Now I may enable SSL in my site. In such a case will the above system work or I need to change code. Will http in url work or i need to change it to https.
    You'll need to change it since the http reference won't exist. Otherwise, what would be the point?

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2004
    Location
    India
    Posts
    453

    Post Re: downloading from https and not http

    Quote Originally Posted by techgnome View Post
    You'll need to change it since the http reference won't exist. Otherwise, what would be the point?

    -tg
    I thought that http url will automatically be converted or changed to https when fired.

  4. #4
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,269

    Re: downloading from https and not http

    Quote Originally Posted by greatchap View Post
    I thought that http url will automatically be converted or changed to https when fired.
    This has to be configured on your server. Many sites today respond to an http protocol URL by issuing a redirect header to an https protocol URL. But it's not an automatic feature of HTTP.

    This isn't a good general solution but we learned long ago in our app that URLs aren't as constant as we'd like. Now when we add a new URL for some web service, we always add it as a setting. Part of our app downloads the user's settings from our server every login, so this lets us change URLs on the fly and if users have an old URL we can tell them to sign off and sign back in to get the correct one.

    It's also a big boon for testing, as it makes it really easy to duck into the settings and change the URL to point at a test server.
    This answer is wrong. You should be using TableAdapter and Dictionaries instead.

  5. #5
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    31,336

    Re: downloading from https and not http

    As Sitten noted, it's an automatic thing, and it has to be configured on the server with a redirect. As an example, with our app, when an unsecure URL is requested, we actually redirect to the landing page, which is two pages removed from the login page... And while that tends to work with browsers, I think that's less likely to work with webclient because I'm not sure how it reacts to redirects.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2004
    Location
    India
    Posts
    453

    Re: downloading from https and not http

    Thank you for your reply.

    The thing is my application (.net windows application) which downloads files and calls php scripts using hardcorded urls such as "http://www.example.com/xyz.txt" will no longer work. This will be big problem.

    Is there any round off ? My server is a linux server running centos.

  7. #7
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,269

    Re: downloading from https and not http

    If you can't change your server, you have to change the app, or vice versa. Sometimes we can't get a pony for Christmas.
    This answer is wrong. You should be using TableAdapter and Dictionaries instead.

  8. #8
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    31,336

    Re: downloading from https and not http

    So you either need to not hardcode them, or change them and release a new version. Bottom line is that the code has to be changed somehow.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2004
    Location
    India
    Posts
    453

    Re: downloading from https and not http

    If I remove http from all the urls and just use www.example.com/abc.txt and so on then will it work if I shift to https.

  10. #10
    Fanatic Member PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Newport, UK
    Posts
    631

    Re: downloading from https and not http

    Probably not, IIRC the OpenRead method requires a full url including protocol.

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2004
    Location
    India
    Posts
    453

    Re: downloading from https and not http

    The command my.computer.network.downloadfile("https://www.example.com/abc.txt","abc.txt") is working in all version of windows except XP.

    What could be the issue ?

  12. #12

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2004
    Location
    India
    Posts
    453

    Re: downloading from https and not http

    Will be glad if anyone can help me.

  13. #13
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,269

    Re: downloading from https and not http

    As of about October, a lot of older encryption protocols are considered so insecure they are illegal to use for many tasks. Because of that, the bulk of people who implement HTTPS decided to move on to more modern standards so as not to worry about compliance.

    But older versions of Windows or older versions of web browsers don't have newer crypto suites, and some are so old there won't be updates. That's probably why XP isn't working: it's about 7 versions of Windows behind and hasn't been supported since 2014.
    This answer is wrong. You should be using TableAdapter and Dictionaries instead.

  14. #14

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2004
    Location
    India
    Posts
    453

    Re: downloading from https and not http

    Quote Originally Posted by Sitten Spynne View Post
    As of about October, a lot of older encryption protocols are considered so insecure they are illegal to use for many tasks. Because of that, the bulk of people who implement HTTPS decided to move on to more modern standards so as not to worry about compliance.

    But older versions of Windows or older versions of web browsers don't have newer crypto suites, and some are so old there won't be updates. That's probably why XP isn't working: it's about 7 versions of Windows behind and hasn't been supported since 2014.
    So are you sure that in Windows XP I won’t be able to download files if the server by default runs on https.

  15. #15
    Lively Member
    Join Date
    Nov 2017
    Posts
    84

    Re: downloading from https and not http

    Does the Windows XP device you are trying this on have Service Pack 3 installed?
    What happens if, from that Windows XP device, you open Internet Explorer and try to access the same file that your program tries to access?
    Last edited by OptionBase1; Dec 26th, 2017 at 02:25 PM.

  16. #16

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2004
    Location
    India
    Posts
    453

    Re: downloading from https and not http

    Yes Win XP has SP3 installed. Through IE I am able to download but through app i get error underlying connection was closed. an unexpected error occurred on send

  17. #17
    Lively Member
    Join Date
    Nov 2017
    Posts
    84

    Re: downloading from https and not http

    Quote Originally Posted by greatchap View Post
    Yes Win XP has SP3 installed. Through IE I am able to download but through app i get error underlying connection was closed. an unexpected error occurred on send
    Out of curiosity, when testing the download with IE did you get any SSL certificate errors or warnings? Also, do you have all of the latest Service Packs and updates installed for the .NET Framework? I know some .NET Framework updates were classified as Optional, so they might not have been installed automatically via Windows Update depending on how it is configured. Try running a manual Windows Update (which I think still works for XP) and check the Optional updates for updates to the .NET Framework.

    There is code on the following page that might help in any event.

    https://stackoverflow.com/questions/...ke-we/43349803

    The code is about 2/3 down the page, right after the sentence saying "To Download a file you can disable..." It appears that you can temporarily disable SSL certificate validation before attempting to download the file. You should be able to add code to your program to check if the OS is XP or not, and if so, add the very long line of code to disable (and then the shorter line re-enable after the download) the certificate validation.
    Last edited by OptionBase1; Dec 26th, 2017 at 02:40 PM.

  18. #18

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2004
    Location
    India
    Posts
    453

    Re: downloading from https and not http

    When I tried through IE it worked in XP and I was not asked for any certificate etc. In other version of windows the download command is working fine. In XP only the my.computer.network.download command or web client downloadfile is giving error that I had already stated.

    Is it possible to download file via XP if I specify https?

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.