Accessing website (untrusted SSL / HTTPS) using urlread

17 views (last 30 days)
Hi.
I have been trying to access a website and log in using urlread. I keep getting error messages such as
Error using urlreadwrite (line 100)
Error downloading URL. Your network connection may be down or your proxy settings
improperly configured.
Here is my code:
url = 'https://oflxd21.dwd.de/cgi-bin/spp1167/webservice.cgi';
s = urlread(url,'Authentication','Basic','Username','***','Password','****');
I have tried the following solutions, to no avail:
  • Added the website's SSL certificate as trusted to MATLAB's JRE's keystore
  • Added the website's SSL certificate as trusted in the JAVA control panel
  • attempted access with urlread2 & urlread_auth from Stackexchange
  • attempted the following line:
s = urlread(url,'post',{'myusername','mypassword'})
which returns the error "could not post to url"
urlread2 returns the error:
Java exception occurred:
javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No
subject alternative DNS name matching oflxd21.dwd.de found.
  • tried adding the line
urlConnection.setRequestProperty('User-Agent','Mozilla 5.0');
to the function urlreadwrite.m
  • tried with firewall turned off
I feel like I am running out of options. Does anyone have any more ideas of what I could try out? My PC is connected to a university network (eduroam). I doubt that I need to add a proxy (it is disabled in preferences). I am pretty sure it has something to do with the SSL certificate being untrusted.
EDIT: I have just found out that the certificate's address is mismatched
Thanks!
- Marc
  1 Comment
Marc Jakobi
Marc Jakobi on 28 May 2015
I have run another test and the line
inputStream = urlConnection.getInputStream;
in urlreadwrite returns the following error:
Java exception occurred:
javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No
subject alternative DNS name matching oflxd21.dwd.de found.
...
Caused by: javax.net.ssl.SSLHandshakeException:
java.security.cert.CertificateException: No subject alternative DNS name matching
oflxd21.dwd.de found.
...

Sign in to comment.

Accepted Answer

Marc Jakobi
Marc Jakobi on 29 May 2015
I give up. I have decided to use cURL via the function
system('curl -k https://oflxd21.dwd.de/...')
with the option -k, and by retrieving the necessary POST commands from FireBug. It works fine now.
  4 Comments
Arda Aksu
Arda Aksu on 15 Oct 2016
Edited: Walter Roberson on 15 Oct 2016
For those who dont know how to install curl as a system app;
1) download the executable
2) extract to any folder you want
3) then you can use the dos command within matlab like this;
[status,result]=dos('"C:\Arda Aksu\curl\bin\curl" https://www.google.com');
...
As you can see "https" links also work while urlread fails. If you use -o option, you can use curl instead of urlwrite as well. See detailed manual at curl website for more information.
...
By the way, Marc thank you for pointing the right direction.

Sign in to comment.

More Answers (0)

Categories

Find more on Downloads in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!