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

后端 未结 11 1011
再見小時候
再見小時候 2020-12-02 06:37

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

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


        
相关标签:
11条回答
  • 2020-12-02 07:12

    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

    3) give the password changeit

    4) enter y

    5) 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**".

    Hope this will work

    0 讨论(0)
  • 2020-12-02 07:13

    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.

    This worked for me.

    0 讨论(0)
  • 2020-12-02 07:18

    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
    

    0 讨论(0)
  • 2020-12-02 07:25

    SOLVED

    1. Just run CMD as an administrator.
    2. Make sure your using the correct truststore password
    0 讨论(0)
  • 2020-12-02 07:28

    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

    C:\Program Files\Java\jre<version>\bin
    

    So, the command should be like

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

    that worked for me.

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题