keytool error: java.io.FileNotFoundException: C:\cacerts (Access is denied)
Asked Answered
B

6

7

I am on Windows 10 with JRE8 and the command I'm using is:

C:\Program Files\Java\jre1.8.0_60\bin>keytool -keystore "C:\cacerts" -storepass changeit -importcert -file "C:\Users\MyUser\Desktop\sf.cer" -alias Symantec_Secure_Server_Class_3

Here's what I've tried so far:

  1. Gave the cacerts file full access to my user (eventhough I am an admin)
  2. Ran keytool as System Administrator in cmd
  3. Put cacerts in different locations (even tried C:\cacerts)

I keep getting the same error:

Certificate was added to keystore keytool error: java.io.FileNotFoundException: C:\cacerts (Access is denied)

What else can I do to import this certificate into my cacerts file?

Beneficiary answered 3/9, 2015 at 22:14 Comment(0)
M
20

Try running the command line as administrator and do it again

Malady answered 7/12, 2016 at 12:27 Comment(0)
L
4

Use the below command:

keytool -genkey -v -keystore test.keystore -alias testkeystore -keyalg RSA -keysize 2048 -validity 10000

the issue was that I was not giving the filename i.e. {test.keystore} which needs to be created as keystore file.

This will resolve the issue.

Lidia answered 13/1, 2020 at 9:33 Comment(0)
J
1

Try putting on another drive: D:\tmp or C:\tmp (other than root).

Jonahjonas answered 3/9, 2015 at 22:18 Comment(0)
B
1

I ended up switching to another computer running Windows 8 with JRE7 and it worked!

UPDATE: Windows Defender was blocking access to the cacerts file. I disabled the brick wall tool and everything is good now!

Beneficiary answered 3/9, 2015 at 22:36 Comment(0)
I
1

If you are running keytool command on linux and facing similar issue, then run this keytool with sudo.

sudo keytool -genkey -alias amq-server -keyalg RSA -keystore amq-server.ks

Ifc answered 13/10, 2021 at 11:23 Comment(0)
G
0

Make sure you are initializing certificates in Administrator mode. This can be done by right clicking over command prompt> Run as administrator(in case of Windows 8 or above). If in win 7, Go to Programs>Accessories>Command prompt>Right Click>Run as Administrator.

Then in cmd use below command(Make sure u are certificate directory): keytool -import -file staging.cer -keystore "%Certificate_destination %" -storepass changeit -alias "%Cerificate_name%"

Gloaming answered 26/5, 2020 at 15:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.