0

While trying to scrape data from a website using urlread2, I got an error message with the following Java exception: 'Could not generate DH keypair'

In the past, I had used urlread2 effectively with HTTP. That fact combined with the Java exception above made it easy to determine that urlread2 was having problems negotiating the SSL handshake, which begged the question...

How can I get urlread2 to work with HTTPS?

dgoverde
  • 110
  • 2
  • 15

1 Answers1

0

In researching the problem, I came across this Stack Overflow question:

Java: Why does SSL handshake give 'Could not generate DH keypair' exception?

One answer suggested upgrading to the latest JDK (1.8.0_73 as of now.) I did that, but my code still didn't work. It occurred to me that MATLAB might have a default Java Virtual Machine (JVM) setting that might need to be changed, so I looked for instructions on how to do that.

I found such instructions here: Change MATLAB Compiler Runtime jvm version

And here: Matlab Central: How do I change the Java Virtual Machine?

After upgrading to the latest JDK and changing the default JVM settings for MATLAB, urlread2 now works with HTTPS.

Community
  • 1
  • 1
dgoverde
  • 110
  • 2
  • 15
  • 1
    I recommend not to change the jvm. Matlab itself is implemented to a large part in Java and only tested with the jvm it ships. – Daniel Feb 17 '16 at 04:19
  • 1
    @Daniel - Yes, I've seen that comment elsewhere, but I figured that I could change it back after scraping the website. But thanks for adding that fact: I had meant to include it in the original question/answer. – dgoverde Feb 17 '16 at 05:48