Ginger
Ginger

Reputation: 8630

Using Matlab and urlread to read data from https?

I am trying to download a https page using url read:

str=urlread('https://funds.barclaysstockbrokers.co.uk/clients/bsl/search_factsheet_summary.aspx?code=B0XWN14')

Unfortunately, I get an error :

Error downloading URL. Your network connection may be down or your proxy settings improperly configured.

I tried using urlread2 (http://www.mathworks.co.uk/matlabcentral/fileexchange/35693-urlread2/content/urlread2.m)

but that gives me this error:

Response stream is undefined
 below is a Java Error dump (truncated):
??? Error using ==> urlread2 at 217
Java exception occurred:
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

What do I need to do?

Upvotes: 1

Views: 4090

Answers (3)

Elkin Garcia
Elkin Garcia

Reputation: 1

After matlab 2014b you can use:

DATA = webread(URL)

This new API does not have all the issues urlread command has.

Upvotes: 0

Jimbo
Jimbo

Reputation: 3284

Here's what I did:

http://www.mathworks.com/matlabcentral/answers/39563-managing-public-key-certificates-in-matlab

Brief Summary: It involved using Chrome to export the certificate then using http://portecle.sourceforge.net/ to add the certificate to Matlab's Java's cacerts file

Upvotes: 1

Nasser
Nasser

Reputation: 13141

It is a certificate security trust issue.

I tried the same command in Mathematica, and got this nice looking pop-up window asking me if I want to accept the certificate

str="https://funds.barclaysstockbrokers.co.uk/clients/bsl/search_factsheet_summary.aspx"
Import[str]

enter image description here

When I clicked on accept for this session only, then I got the data OK

I do not use urlread(). But at least now you know why. I do not see options in urlread to do the above. May be you need another API in Matlab to do what you want. May be something at matlab file exchange might handle this.

Upvotes: 0

Related Questions