MATLAB: Accessing website (untrusted SSL / HTTPS) using urlread

authenticationcertificatehttpsssluntrustedurlread

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

Best Answer

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.