无法在使用jpackage时打开Windows-MY密钥库。

huangapple go评论65阅读模式
英文:

Can not open Windows-MY keystore when using jpackage

问题

问题:

在使用JPackage创建Windows可执行文件时,无法使用KeyStore。它返回一个错误。

代码:

KeyStore.getInstance("Windows-MY");

会抛出异常:

java.security.KeyStoreException: 找不到 Windows-MY
  at java.base/java.security.KeyStore.getInstance(Unknown Source)
 ...
Caused by: java.security.NoSuchAlgorithmException: Windows-MY密钥库不可用
  at java.base/sun.security.jca.GetInstance.getInstance(Unknown Source) at java.base/java.security.Security.getImpl(Unknown Source)

在Windows上运行jpackage并尝试执行KeyStore.getInstance("Windows-MY");会返回上述错误。

在IDE中运行应用程序而不使用JPackage可以正常工作。

英文:

Problem:

Using JPackage to create an executable for Windows does not work with KeyStore. It returns an error.

Code:

KeyStore.getInstance("Windows-MY");

will throw exception:

java.security.KeyStoreException: Windows-MY not found
  at java.base/java.security.KeyStore.getInstance(Unknown Source)
 ...
Caused by: java.security.NoSuchAlgorithmException: Windows-MY KeyStore not available
  at java.base/sun.security.jca.GetInstance.getInstance(Unknown Source) at java.base/java.security.Security.getImpl(Unknown Source)

Running the jpackage for Windows and trying to execute KeyStore.getInstance("Windows-MY"); returns the error above.

Running the application in the IDE without JPackage works fine.

答案1

得分: 5

Windows-MY密钥库的支持是jdk.crypto.mscapi模块的一部分。我猜这在您当前通过jpackage进行的设置中并未包含。我对模块的经验有限,但我猜您需要在您的module-info.java中添加requires jdk.crypto.mscapi;,或者如您在评论中提到的,通过jpackage命令行使用--add-modules添加它(例如,--add-modules jdk.crypto.mscapi)。

英文:

The support for the Windows-MY keystore is part of the module jdk.crypto.mscapi. I guess this doesn't get included with your current setup through jpackage. I don't have much experience with modules, but I guess you need to add requires jdk.crypto.mscapi; to your module-info.java, or - as you mentioned in the comments - add it to the jpackage command line with --add-modules (e.g. --add-modules jdk.crypto.mscapi).

huangapple
  • 本文由 发表于 2023年5月24日 19:25:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/76323022.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定