MATLAB:如何让urlread2与HTTPS协同工作(MATLAB: How to get urlread2 to work with HTTPS)

在尝试使用urlread2从网站抓取数据时,我收到一条错误消息,其中包含以下Java异常:“无法生成DH密钥对”

在过去,我曾经有效地使用urlread2和HTTP。 这个事实加上上面的Java异常使得很容易确定urlread2在协商SSL握手时遇到了问题,这就提出了一个问题......

如何让urlread2与HTTPS一起使用?

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?

最满意答案

在研究这个问题时,我遇到了这个Stack Overflow问题:

Java:为什么SSL握手会给出“无法生成DH密钥对”的异常?

一个答案建议升级到最新的JDK(截至目前为1.8.0_73)。我做到了,但我的代码仍然无效。 我想到MATLAB可能有一个可能需要更改的默认Java虚拟机(JVM)设置,因此我查找了有关如何执行此操作的说明。

我在这里找到了这样的指令: 更改MATLAB Compiler Runtime jvm版本

在这里: Matlab Central:如何更改Java虚拟机?

升级到最新的JDK并更改MATLAB的默认JVM设置后, urlread2现在可以使用HTTPS。

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.

更多推荐