简体   繁体   中英

Using keytool to install a security certificate

I had this problem and could not find much help online so I think I will post the solution to this problem myself as I'm sure some more people also must be facing this same problem and hope it helps someone.

I had to install an SSL certificate using keytool. As per instructions, I was to type this into my command line (Linux):

    sudo keytool -import -trustcacerts -alias SERVER -file /PATH/TO/CERT -keystore /PATH/TO/JAVA/lib/security/cacerts

Unfortunately, I do not have Linux on my personal laptop, I have Windows 8. As most people doing this kind of stuff, do it in Linux, help online for Windows was minimal.

This is how I did it:

  1. Open command prompt in administrator mode. This is very important as, if you don't have admin rights, you will simply be denied access. Click here to see how to do this.

  2. Enter the following in command prompt (admin) (NOTICE sudo is left out)

     keytool -import -trustcacerts -alias SERVER -file /PATH/TO/CERT -keystore /PATH/TO/JAVA/lib/security/cacerts 

with the following replacements:

a. Replace SERVER to the name of the server whose certificate you want to install. eg. scruffy.something.something.de.

b. Replace /PATH/TO/CERT with the full path of the certificate you have downloaded. This must include the filename with extension as well. If you enter only the directory path, you will again get an "Access is denied" error.

c. Replace /PATH/TO/JAVA with the path of Java_Home. To find this, follow Step 4.

  1. To find the path of Java_Home (if you're using Eclipse), Go to Help in the top ribbon in Eclipse. Help --> About Eclipse --> Installation Details --> Configuration tab. Select all the text in the configuration tab and paste it in a text editor. Use Ctrl + F to find java.home. And the path by the side of this is what you need to put in Step 3. If not using Eclipse, you can find this Java_Home from your environment variables in Control Panel.

  2. If you do all the above steps correctly, you should be prompted for the Java keystore password. If you have not changed this password, it's default value is changeit (or, on certain versions of Mac OS X, changeme ).

  3. When you type it, no characters will be displayed on the screen. This is normal. Hit Enter.

  4. If everything is ok, you will be asked whether you trust the certificate. Type yes.

  5. That's it! The certificate will be installed if all above steps are correctly done.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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