Keytool error java io filenotfoundexception cacerts access is denied

Keytool error: java.io.FileNotFoundException: cacerts (Access is denied)

This question has been asked several times but none of the solutions work for me. I running the DOS command window as Administrator, but when running the keytool command to install a certificate I get the error above:

C:\Program Files\Java\jdk1.8.0_191\jre\lib\security>keytool -import -file xxx.yyy.zzz.crt -alias xxxx.yyy.zzz.com -keystore cacerts -storepass changeit -noprompt Certificate was added to keystore keytool error: java.io.FileNotFoundException: cacerts (Access is denied) 

I’m on Windows 10 with JDK 1.8.0_191. Why would access be denied to the Administator?

Best Solution

I have faced the same issue.

Here is the solution what I found:

  1. Copy the cacert file other than Java folder [May be D drive or desktop].
  2. Update the path of cacert file path in your command [Sated in question].
  3. Run your query. [You wont get the io exception].
  4. Then replace the new cacert file in the original location.
Error adding certificate to cacerts. Unknown key spec

You may have two or more jdk’s installed on your machine. One thing, which you can try, is go to your target jdk. In your case it is

C:\Program Files\Java\jdk1.6.0_27\bin 

Then run your command, Once it is working, then make sure that your PATH variable is configured properly to the targeted JDK’s bin.

Читайте также:  Building web pages with php
Java – keytool : Certificate import gives error message – Keystore was tampered with, or password was incorrect

I have got this sorted out. I was using my password that is ‘password’ to update cacerts keystore in JDK while default password for cacerts keystore is ‘changeit’

Related Question

Источник

Ошибка Keytool Java после импорта сертификата, «ошибка keytool: java.io.FileNotFoundException & Access Denied»

Наконец, когда я проверил хранилище ключей, сертификат SSL не был добавлен, и мое приложение дает то же исключение, которое я получал раньше при попытке подключения:

(javax.net.ssl.SSLHandshakeException:sun.security.validator.ValidatorException) 

Не могли бы вы опубликовать точную команду keytool которую вы выполнили, и ее вывод? некоторые из очевидных проблем здесь — опечатка аргумента -keystore и тот факт, что keytool не удалось найти хранилище ключей для импорта ключа в

Я хотел написать: keytool -import -aliasloadedCertAlias -keystore C: \ path \ to \ my \ keystore \ cacerts.file -file C: \ path \ of \ exportedCert.cer Я также упомянул команду, выполненную без ошибок, поэтому очевидно это просто орфографическая ошибка в моем вопросе . В любом случае спасибо

10 ответов

Это может произойти, если вы не используете командную строку в режиме администратора. Если вы используете Windows 7, вы можете запустить команду, введите cmd и нажмите Ctrl + Shift + enter. Это откроет командную строку в режиме администратора. Если нет, вы также можете запустить → все программы → аксессуары → щелкнуть правой кнопкой мыши и сказать «запустить как администратор».

Запуск от имени администратора не является правильным решением. Большинство компаний блокируют доступ администратора. Лучше установить причину, по которой в доступе отказано, а не в увеличении преимуществ.

У меня была такая же проблема в Windows, и я смог ее решить, запустив cmd.exe в качестве администратора (щелкните правой кнопкой мыши в меню «Пуск», затем «Запуск от имени администратора» ).

Проверьте разрешения на запись в хранилище ключей.

У меня была та же проблема при импорте сертификата в локальное хранилище ключей. Всякий раз, когда я выдаю команду keytool, я получил следующую ошибку.

Сертификат был добавлен в хранилище ключей keytool error: java.io.FileNotFoundException: C:\Program Files\Java\jdk1.8.0_151\jre\lib\security (доступ запрещен)

Следующее решение работает для меня.

1) убедитесь, что вы запускаете командную строку на Rus в режиме администратора

2) Измените текущий каталог на% JAVA_HOME%\jre\lib\security

3), затем выполните команду ниже

keytool -import -alias «mycertificatedemo» файл «C:\Users\name\Downloads\abc.crt» -keystore cacerts

5) вы увидите следующее сообщение об успешном «Сертификат был добавлен в хранилище ключей»

Убедитесь, что вы указываете » cacerts» только в значении параметра -keystore, поскольку я передавал полный путь, как «C **:\Program Files\Java\jdk1.8.0_151\JRE\Lib\безопасность **».

Надеюсь, что это сработает

Как упомянуто здесь, для меня работало то, что я на самом деле находился в каталоге безопасности и давал только имя «cacerts» для сертификата вместо полного пути.

Источник

Java Keytool error after importing certificate , «keytool error: java.io.FileNotFoundException & Access Denied»

I’m trying to connect a Java Web API via HTTPS; however, an exception is thrown:

javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException 

I followed these steps which I learned from online keytool & SSL cert tutorials:

  1. I copied the HTTPS URL into the browser, downloaded the SSL certificates & Installed them in the browser using Internet Explorer.
  2. Exported the certificates to a path on my computer, the certificates were saved as .cer
  3. Used the keytool’s import option. The command below executed without any errors.
 keytool -import -alias downloadedCertAlias -keystore C:\path\to\my\keystore\cacerts.file -file C:\path\of\exportedCert.cer 

However after that message, another exception was displayed:

 keytool error: java.io.FileNotFoundException: C:\Program files\. \cacerts

Finally when I checked the keystore , the SSL certificate was not added and my application gives the same exception I was getting earlier when trying to connect:

(javax.net.ssl.SSLHandshakeException:sun.security.validator.ValidatorException) 

Java Solutions

Solution 1 — Java

This could happen if you are not running the command prompt in administrator mode. 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. If not, you can also go to start -> all programs -> accessories -> right click command prompt and click ‘run as administrator’.

Solution 2 — Java

I was having the same problem while importing the certificate in local keystore. Whenever i issue the keytool command i got the following error.

Certificate was added to keystore keytool error: java.io.FileNotFoundException: C:\Program Files\Java\jdk1.8.0_151\jre\lib\security (Access is denied)

Following solution work for me.

  1. make sure you are running command prompt in Rus as Administrator mode
  2. Change your current directory to %JAVA_HOME%\jre\lib\security
  3. then Issue the below command

keytool -import -alias «mycertificatedemo» -file «C:\Users\name\Downloads\abc.crt» -keystore cacerts

  1. give the password changeit
  2. enter y
  3. you will see the following message on successful «Certificate was added to keystore»

Make sure you are giving the «cacerts» only in -keystore param value , as i was giving the full path like «C**:\Program Files\Java\jdk1.8.0_151\jre\lib\security**».

Solution 3 — Java

I had the same problem under Windows and could solve it by running cmd.exe as administrator (right-click in start menu, then «Run as administrator).

Solution 4 — Java

Check the write permissions on the keystore.

Solution 5 — Java

For Mac users make sure to sudo and when prompted first give your administrator password and that will be followed by keystore password which typically should be «changeit» unless you actually changed it.

Solution 6 — Java

If you are using windows8:

  1. Click start button
  2. In the search box, type command prompt
  3. From the result, right-click command prompt and click Run as administrator . Then execute the keytool command.

Solution 7 — Java

You can give yourself permissions to fix this problem.

Right click on cacerts > choose properties > select Securit tab > Allow all permissions to all the Group and user names.

Solution 8 — Java

I got this error too even I ran cmd as an Administrator.

The root cause is: The file is from VCS(subversion, perforce, etc.), and when I checked the properties of this file, its’ Attributes is Read-only.

  • (1) disable the ‘Read-only’ Attribute;
  • (2) check out from VCS, let the file under the status of read&write.

Solution 9 — Java

I even run the command prompt as Administrator but it didn’t work for me with the below error.

'keytool' is not recognized as an internal or external command, operable program or batch file. 

If the path to the keytool is not in your System paths then you will need to use the full path to use the keytool, which is

So, the command should be like

"C:\Program Files\Java\jre\bin\keytool.exe" -importcert -alias certificateFileAlias -file CertificateFileName.cer -keystore cacerts 

Solution 10 — Java

Make sure you running as Administrator. In Mac terminal:-

Solution 11 — Java

You can store orther disk or path (not C) EX : D\

C:\Program Files\Java\jre1.8.0_101\bin>keytool -genkey -alias server -keyalg RSA -keysize 2048 -keystore D:\myserver.jks -dname "CN=myserver,OU=IT-WebDev, O=TIACHOP, L=HCM, ST=0753, C=VN" && keytool -certreq -alias server -file D:\myserver.csr -keystore D:\myserver.jks 

enter image description here

Solution 12 — Java

  1. Just run CMD as an administrator.
  2. Make sure your using the correct truststore password

Источник

keytool error java.io.FileNotFoundException: (Access is denied)

keytool manages and manipulates a keystore, a repository for public and private keys and public key certificates. keytool defines various commands for generating keys, importing data into the keystore, and exporting and displaying keystore data. Keys and certificates are stored in a keystore using a case-insensitive name or alias. keytool uses this alias to refer to a key or certificate.

The Problem

You launched the Command Prompt to create a keystore as below, and in the end the error occurred.

$ keytool -genkey -alias mykeystore -keyalg RSA -keystore KeyStore.jks -keysize 2048 Enter keystore password: Re-enter new password: What is your first and last name? [Unknown]: joysu What is the name of your organizational unit? [Unknown]: ps What is the name of your organization? [Unknown]: ddw What is the name of your City or Locality? [Unknown]: ocoee What is the name of your state or province? [Unknown]: fl What is the two-letter country code for this unit? [Unknown]: us Is CN=joysu, OU=ps, O=ddw, L=ocoee, ST=fl, C=us correct? [No]: yes Enter key password for ,jkskeystore. (RETURN if same as keystore password): keytool error: java.io.FileNotFoundException: keystore.jks (Access is denied)

The Solution

Change the directory and file access permission to allow you to access the file.

If change access permission does not solve the problem, launch the Command Prompt as an administrator. Right click on Command Prompt and select “Run as administer”.

Final Thoughts

The JDK provides a command-line utility named keytool for manipulation of the keystore key database. This tool is run from the command line and accepts a number of parameters that allow it to be used to create new certificates, to import certificates, to delete certificates, or to generate certificate-signing requests (CSRs) for Certificate Authorities. In this post we have seen how to resolve the error “keytool error java.io.FileNotFoundException: (Access is denied)”.

Источник

Оцените статью