简体   繁体   English

java.io.FileNotFoundException: (Operation not allowed) error with ./keytool -import on mac osx (el capan) - Java 6

[英]java.io.FileNotFoundException: (Operation not permitted) error with ./keytool -import on mac osx (el capitan) - Java 6

Trying to import a CA Cert to my Java 6 truststore and am running into this error:尝试将 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)

I'm running that command as root as well so I'd think I have access to that cacerts keystore location.我也以 root 身份运行该命令,因此我认为我可以访问该 cacerts 密钥库位置。 Using Java 6.使用 Java 6。

This seems to be a mac specific issue when the exception states (Operation not permitted) -当异常状态(Operation not permitted)时,这似乎是特定于 mac 的问题 -

For anyone else having this problem you need to reboot your mac and press ⌘+R when booting up.对于遇到此问题的其他人,您需要重新启动 Mac 并在启动时按 ⌘+R。 Then go into Utilities > Terminal and type the following commands:然后进入实用程序>终端并键入以下命令:

csrutil disable
reboot

You should be able to import cacerts to your Java keystore following that.在此之后,您应该能够将 cacerts 导入您的 Java 密钥库。 Don't forget to reenable csrutil after you've imported that cacert.不要忘了重新启用csrutil你导入的CACERT后。 Reboot, press ⌘+R when booting up, Utilities > Terminal, enter:重启,开机时按⌘+R,Utilities > Terminal,输入:

csrutil enable
reboot

I was hit by similar issue on MacOS Big Sur while starting an jnlp file:在启动 jnlp 文件时,我在 MacOS Big Sur 上遇到了类似的问题:

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)

Solution for this was:对此的解决方案是:

  • Give Java ( /usr/bin/java ) Full Disk access授予 Java ( /usr/bin/java )完整磁盘访问权限
  • Give Java ( /usr/bin/java ) Files and Folders access to Downloads, Documents and Folders授予 Java ( /usr/bin/java )文件和文件夹访问下载、文档和文件夹的权限

Steps脚步

  1. Open /usr/bin in Finder, eg by invoking from Terminal:在 Finder 中打开/usr/bin ,例如通过从终端调用:
jhartman@MBP ~ % open /usr/bin
  1. Localise java (and keytool )本地化java (和keytool

  2. Open System Preferences and Security & Privacy .打开系统偏好设置安全与隐私 Open Full Disk Access tab and authorise打开完整磁盘访问选项卡并授权

  3. Drag java and keytool from Finder window opened in step 1 and drop onto the App list in Full Disk Accessjavakeytool从在步骤 1 中打开的 Finder 窗口中拖放到Full Disk Access 中的 App 列表中

在此处输入图片说明

  1. Go to Security & Privacy -> Files and Folders , tick Downloads Folder and Document Folder for java and keytool转到Security & Privacy -> Files and Folders ,勾选 Downloads Folder and Document Folder for java and keytool

在此处输入图片说明

It was solution for my problem but I hope it should also sort out keytool issue.这是我的问题的解决方案,但我希望它也能解决keytool问题。

I was running into this for files under my .metadata directory because I put my Eclipse workspace under Documents.我在 .metadata 目录下的文件中遇到了这个问题,因为我将 Eclipse 工作区放在了 Documents 下。 Get around this by going into System Preferences->Privacy and adding access to particular Files and Folder for Eclipse or giving Eclipse Full Disk Access.通过进入系统偏好设置->隐私并添加对 Eclipse 的特定文件和文件夹的访问权限或授予 Eclipse 全盘访问权限来解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM