简体   繁体   English

使用keytool安装安全证书

[英]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. 我必须使用keytool安装SSL证书。 As per instructions, I was to type this into my command line (Linux): 按照说明,我要在命令行(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. 不幸的是,我的笔记本电脑上没有Linux,而是Windows8。由于大多数人都在Linux中进行此类操作,因此Windows的在线帮助非常少。

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) 在命令提示符(管理员)中输入以下内容(忽略sudo

     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. 将SERVER替换为要安装其证书的服务器的名称。 eg. 例如。 scruffy.something.something.de. scruffy.something.something.de。

b. Replace /PATH/TO/CERT with the full path of the certificate you have downloaded. 将/ PATH / TO / CERT替换为您下载的证书的完整路径。 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. C。 Replace /PATH/TO/JAVA with the path of Java_Home. 将/ PATH / TO / JAVA替换为Java_Home的路径。 To find this, follow Step 4. 要找到此,请按照步骤4。

  1. To find the path of Java_Home (if you're using Eclipse), Go to Help in the top ribbon in Eclipse. 要查找Java_Home的路径(如果使用的是Eclipse),请转到Eclipse顶部功能区中的“帮助”。 Help --> About Eclipse --> Installation Details --> Configuration tab. 帮助->关于Eclipse->安装详细信息->配置选项卡。 Select all the text in the configuration tab and paste it in a text editor. 在配置选项卡中选择所有文本,然后将其粘贴到文本编辑器中。 Use Ctrl + F to find java.home. 使用Ctrl + F查找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. 旁边的路径就是您在步骤3中需要输入的内容。如果不使用Eclipse,则可以从“控制面板”中的环境变量中找到此Java_Home。

  2. If you do all the above steps correctly, you should be prompted for the Java keystore password. 如果正确执行了上述所有步骤,则将提示您输入Java密钥库密码。 If you have not changed this password, it's default value is changeit (or, on certain versions of Mac OS X, changeme ). 如果您尚未更改此密码,则默认值为changeit (或在某些Mac OS X版本中为changeme )。

  3. When you type it, no characters will be displayed on the screen. 键入时,屏幕上不会显示任何字符。 This is normal. 这很正常。 Hit Enter. 按下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. 如果以上所有步骤均正确完成,则将安装证书。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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