Tatkal
Tatkal

Reputation: 568

Keytool error java.io.FileNotFoundException(the system cannot find the file specified)

keytool error: java.io.FileNotFoundException: api.sepa.express.crt (The system cannot find the file specified)

I tried various examples which I found in stackoverflow.

keytool -importcert -file certificate.cer -keystore keystore.jks -alias "Alias"

and

    keytool -import -alias susan
   -file Example.cer -keystore exampleraystore

Tried using cmd as admin. I have placed my certificate file in Desktop. When I'm trying to copy in:

C:\Program Files\Java\jdk1.8.0_60\jre\lib\security

It's not accepting the certificate file.

What would be the preferred way to complete this command?

Upvotes: 3

Views: 35860

Answers (6)

suhas jadhav
suhas jadhav

Reputation: 9

Sometimes we forget to include the file type (.cer or .cert). For example, "xyz.cer" is a file. If the full file name with the file type is not included, the following command will fail:

keytool -importcert -file xyz -keystore keystore.jks -alias "Alias"

To ensure it works, use the full file name with the file type as shown below:

keytool -importcert -file xyz.cer -keystore keystore.jks -alias "Alias"

Upvotes: 0

S. Mayol
S. Mayol

Reputation: 2625

I was getting the similar error when I was trying to run the BAT file:

D:\Accela\av.biz\conf\certs>D:\Accela\bin\jdk1.7.0\jre\bin\keytool.exe -import - noprompt -alias stgdiitehsccatsii.health.dohmh.nycnet -keystore D:\Accela\av.biz \conf\certs\trusted_cacerts -file D:\Accela\av.biz\conf\certs\stgdiitehsccatsii. health.dohmh.nycnet.cer -storepass changeit keytool error: java.io.FileNotFoundException: D:\Accela\av.biz\conf\certs\stgdii tehsccatsii.health.dohmh.nycnet.cer (The system cannot find the file specified)

D:\Accela\av.biz\conf\certs>pause Press any key to continue . . .

I was able to fix it just changing the extension from .cer to .crt on the BAT file code:

D:\Accela\av.biz\conf\certs\stgdiitehsccatsii.health.dohmh.nycnet.cer

to

D:\Accela\av.biz\conf\certs\stgdiitehsccatsii.health.dohmh.nycnet.crt

Since that was the right extension for the certificate file.

Upvotes: 0

Dzmitry Darashuk
Dzmitry Darashuk

Reputation: 525

1.Advice: run Comand Prompt as administrator ( If you are using windows 7, you can go to run, type cmd and hit Ctrl+Shift+enter. This will open the command prompt in administrator mode.)

2.C:...... > keytool -importcert -file "C:part/to/file.crt" -keystore "%JAVA_HOME%\jre\lib\security\cacerts" -alias 1Alias (Do not forget that file with .crt )

3.password - changeit

  1. y - yes.

Upvotes: 0

GITANSH Lamba
GITANSH Lamba

Reputation: 41

Firstly download the certificate into any of your directory, for me I choose (D:\My) where I kept my certificate with the name xyz.cert.

Second, you should be the admin of CMD/Command and write the word "keytool", it should give you the output as :

Key and Certificate Management Tool

Commands:

 -certreq            Generates a certificate request
 -changealias        Changes an entry's alias
 -delete             Deletes an entry
...something like this should be the output 

Third, As all the certificate are kept "cacerts" which is in the directory -
C:\Program Files\Java\jdk1.8.0_172\jre\lib\security

Use the below command from the directory -
C:\Program Files\Java\jdk1.8.0_172\jre\lib\security

keytool -import -alias clojars.org -keystore /cacerts -file D:/My/xyz.cer

Where to find what :

  1. When you double click on the certificate (xyz.cert in my case) it will open a pop up, where you will find in General Tab, Issued to : clojars.org ( this name you need to give in front of -alias)
  2. In front of -keystore should be the path of cacerts but as we are already in the directory C:\Program Files\Java\jdk1.8.0_172\jre\lib\security, so we can just give /cacerts
  3. file --> location of the certificate

If it asks for password, default is changeit, so keep the same everytime

Hope this solves your problem. :)

Upvotes: 4

Muhammad shuja
Muhammad shuja

Reputation: 19

just create file in any other directory than c: Drive for eg: create in d: Drive

Upvotes: 0

Tatkal
Tatkal

Reputation: 568

Try adding the ssl file using command promt. It worked for me

Upvotes: 3

Related Questions