-
Dec 21st, 2017, 05:07 AM
#1
Thread Starter
Fanatic Member
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
-
Dec 21st, 2017, 08:16 AM
#2
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
-
Dec 21st, 2017, 09:59 AM
#3
Thread Starter
Fanatic Member
Re: downloading from https and not http
Originally Posted by techgnome
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.
-
Dec 21st, 2017, 10:40 AM
#4
Re: downloading from https and not http
Originally Posted by greatchap
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.
-
Dec 21st, 2017, 11:08 AM
#5
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
-
Dec 21st, 2017, 12:50 PM
#6
Thread Starter
Fanatic Member
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.
-
Dec 21st, 2017, 02:11 PM
#7
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.
-
Dec 21st, 2017, 02:58 PM
#8
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
-
Dec 22nd, 2017, 12:26 AM
#9
Thread Starter
Fanatic Member
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.
-
Dec 22nd, 2017, 10:26 AM
#10
Re: downloading from https and not http
Probably not, IIRC the OpenRead method requires a full url including protocol.
-
Dec 25th, 2017, 11:13 PM
#11
Thread Starter
Fanatic Member
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 ?
-
Dec 26th, 2017, 11:57 AM
#12
Thread Starter
Fanatic Member
Re: downloading from https and not http
Will be glad if anyone can help me.
-
Dec 26th, 2017, 12:24 PM
#13
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.
-
Dec 26th, 2017, 12:41 PM
#14
Thread Starter
Fanatic Member
Re: downloading from https and not http
Originally Posted by Sitten Spynne
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.
-
Dec 26th, 2017, 12:52 PM
#15
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.
-
Dec 26th, 2017, 01:06 PM
#16
Thread Starter
Fanatic Member
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
-
Dec 26th, 2017, 02:33 PM
#17
Re: downloading from https and not http
Originally Posted by greatchap
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.
-
Dec 27th, 2017, 04:16 AM
#18
Thread Starter
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|