Accessing website (untrusted SSL / HTTPS) using urlread

16 ビュー (過去 30 日間)
Marc Jakobi
Marc Jakobi 2015 年 5 月 28 日
編集済み: Walter Roberson 2016 年 10 月 15 日
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 件のコメント
Marc Jakobi
Marc Jakobi 2015 年 5 月 28 日
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.
...

サインインしてコメントする。

採用された回答

Marc Jakobi
Marc Jakobi 2015 年 5 月 29 日
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 件のコメント
Arda Aksu
Arda Aksu 2016 年 10 月 15 日
編集済み: Walter Roberson 2016 年 10 月 15 日
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.
Marc Jakobi
Marc Jakobi 2016 年 10 月 15 日
Cheers for the additional input.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDownloads についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by