java.io.FileNotFoundException : (Operation not permitted) error with ./keytool - 在 mac osx (el capitan) 上导入 - Java 6

标签 java ssl ssl-certificate

尝试将 CA 证书导入我的 Java 6 信任库并遇到此错误:

./keytool -v -import -trustcacerts -alias Rapidssl -file /Users/spurr/Desktop/rapidssl.cer -keystore /System/Library/Java/Support/CoreDeploy.bundle/Contents/Home/lib/security/cacerts
Enter keystore password:
Certificate was added to keystore
[Storing /System/Library/Java/Support/CoreDeploy.bundle/Contents/Home/lib/security/cacerts]
keytool error: java.io.FileNotFoundException: /System/Library/Java/Support/CoreDeploy.bundle/Contents/Home/lib/security/cacerts (Operation not permitted)
java.io.FileNotFoundException: /System/Library/Java/Support/CoreDeploy.bundle/Contents/Home/lib/security/cacerts (Operation not permitted)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:194)
at java.io.FileOutputStream.<init>(FileOutputStream.java:84)
at sun.security.tools.KeyTool.doCommands(KeyTool.java:902)
at sun.security.tools.KeyTool.run(KeyTool.java:172)
at sun.security.tools.KeyTool.main(KeyTool.java:166)

我也以 root 身份运行该命令,因此我认为我可以访问该 cacerts keystore 位置。使用 Java 6。

最佳答案

我在 MacOS Big Sur 上启动 jnlp 文件时遇到了类似的问题:

CouldNotLoadArgumentException[ Could not load file/URL specified: /Users/jhartman/Documents/Favorities/NCC/NCC 123.jnlp]
....
Caused by: java.io.FileNotFoundException: /Users/jhartman/Documents/Favorities/NCC/NCC 123.jnlp (Operation not permitted)

解决方案是:

  • 授予 Java ( /usr/bin/java) 完整磁盘访问权限
  • 授予 Java ( /usr/bin/java ) 文件和文件夹访问下载、文档和文件夹的权限

步骤

  1. 打开/usr/bin在 Finder 中,例如通过从终端调用:
jhartman@MBP ~ % open /usr/bin
  1. 本地化 java (和 keytool)

  2. 打开系统偏好设置安全与隐私。打开Full Disk Access标签并授权

  3. 拖动 javakeytool从在第 1 步打开的 Finder 窗口中拖放到 Full Disk Access

    中的 App 列表

enter image description here

  1. 转到安全和隐私 -> 文件和文件夹,勾选java 的下载文件夹和文档文件夹|和 keytool

enter image description here

这是我的问题的解决方案,但我希望它也能解决 keytool问题。

关于java.io.FileNotFoundException : (Operation not permitted) error with ./keytool - 在 mac osx (el capitan) 上导入 - Java 6,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41747473/

相关文章:

java - 退出后避免返回页面渲染

postgresql - 为 Postgres 连接向 Tomcat 提供证书

java - SSL套接字服务器在握手后获取证书cn

android - Facebook 安卓 : "Security Error: There are problems with the security certificate for this site"

php - wamp 上的 SSL 证书错误

amazon-web-services - 使用 cloudformation 在 Apache 上安装证书

google-chrome - 仅 Chrome 上的 ERR_SSL_VERSION_OR_CIPHER_MISMATCH 错误

Java 最好的保持价格的类型

java - EAR 文件的绝对路径

java - 为 java 项目创建 .exe