如何设置 Java VM 以使用 Mac OS X 处理的根证书(信任库)

我在使用 scribe OAuth 库时遇到以下异常.

I get the following exception while using the scribe OAuth library.

Caused by: javax.net.ssl.SSLException: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty

根据一些谷歌搜索,我似乎应该以某种方式设置 JVM 信任库.

Based on some googling it seems I should set up the JVM truststore somehow.

为什么我需要这样做?如何指示 Java VM 使用操作系统的默认信任库?(在我的例子中是 Mac OS X).

Why do I need to do this? How can I instruct the Java VM to use the default truststore of the os? (Mac OS X in my case).

推荐答案

我可以通过在启动 VM 时添加此系统属性来设置默认信任库:

I can setup the default truststore by adding this system propery when launching the VM:

-Djavax.net.ssl.trustStore=/Library/Java/Home/lib/security/cacerts

我仍然不明白为什么我需要这样做.这应该是默认值.每次添加这个也很烦人.有没有更好的方法,例如一些操作系统设置?

I still don't understand why do I need to do this. This should be the default. It's also very annoying to add this every time. Is there a better way, e.g. some OS settings?

相关文章