将 SSL 证书导入 Eclipse
如何将java创建的SSL证书导入到Eclipse中的项目中?
How do you import an SSL certificate created by java into a project in Eclipse?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
如何将java创建的SSL证书导入到Eclipse中的项目中?
How do you import an SSL certificate created by java into a project in Eclipse?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(8)
如果您的 Windows 证书存储中已有该证书(这在使用 MITM 证书的公司/公司部署中很常见),您还可以使用以下步骤(在 另一个带有更详细解释的 Stackoverflow 答案):
在 Eclipse 安装中找到
eclipse.ini
文件并打开它在
-vmargs
行下方,添加以下行,然后保存文件:In case you have the certificate already in your Windows' certificate store (this is common in corporate/company deployments with MITM certificates), you can also use the following steps (with help from another Stackoverflow answer with more detailed explaination):
Locate the
eclipse.ini
file in your Eclipse installation and open itBelow the line
-vmargs
, add the following lines, then save the file:您可能希望在 JRE 的 trustcacerts 中导入“假”SSL 证书,以避免证书无效的问题。 不是吗?
正如乔恩所说,您可以使用 keytool:
在询问时使用“changeit”作为默认密码(感谢 Brian Clozel)。 确保在您的服务器或启动配置中使用此运行时。
Probably you want to import a "fake" SSL cert in JRE's trustcacerts for avoiding not-a-valid-certificate issues. Isn't it?
As Jon said, you can do the job with keytool:
Use "changeit" as the default password when asked (thanks Brian Clozel). Ensure to use this runtime at your server or launch configuration.
有一个更好的工具可以完成这项工作。
KeyStore Explorer
当您运行时(在 Windows 中以管理员身份运行以便保存对系统的更改), sudo linux等)应用程序(它有win / mac / linux的安装程序)有一个内置功能可以编辑系统的cacerts文件:
文件->; 开放特价 -> 打开 CA 证书
只要你已经有了证书文件,你可以进入:
工具->CA 导入可信证书
或者您需要从服务器下载证书; 转到:
检查-> 检查 SSL
从那里输入主机名,然后单击“确定”。 它将弹出一个窗口,显示证书详细信息。 该窗口底部有一个“导入”按钮,可让您直接将其导入到 cacerts 中。
确保保存并关闭 cacerts,然后重新启动 eclipse/应用程序以使设置生效。
There's a better tool for the job.
KeyStore Explorer
When you run (run as administrator in windows in order to save changes to system, sudo in linux, etc.) the application (it has installers for win/mac/linux) there's a built-in function to edit the system's cacerts file:
File -> Open Special -> Open CA Certificates
EITHER you already have the certificate file and you can go to:
Tools -> Import Trusted Certificate
OR you need to download the certificate from the server; go to:
Examine -> Examine SSL
From there type in the hostname and click ok. It will pop up a window showing the certificate details. At the bottom of that window there's an "Import" button that will allow you to directly import it into the cacerts.
Make sure you save and close cacerts, and restart your eclipse/application for the settings to take effect.
Mac
example.cer
)并右键单击 ➡️ 选择 导出... ➡️ 将其保存到某个位置,例如桌面
。密钥库的默认密码是:
changeit
。$JAVA_HOME/lib/security
指向系统中的/Library/Java/JavaVirtualMachines/adoptopenjdk-15.jdk/Contents/Home/lib/security
,添加eclipse.ini
文件中包含以下几行:注意: 如果您使用的是 STS,请按照 此答案 找到
.ini
文件。Mac
example.cer
) and right-click ➡️ Select Export... ➡️ Save it to some location e.g.Desktop
.The default password of the keystore is:
changeit
.$JAVA_HOME/lib/security
points to/Library/Java/JavaVirtualMachines/adoptopenjdk-15.jdk/Contents/Home/lib/security
in your system, add the following lines in theeclipse.ini
file:Note: If you are using STS, follow this answer to locate the
.ini
file.我们需要导入证书意味着我们需要使用:
它将要求输入密码。 输入密码
changeit
最后它会询问是否需要添加 {yes/no} :
输入 yes。
注意:位置路径中不要留有空格
We need to import a certificate means we need to use :
It will ask for a password. Type the password as
changeit
finally it will ask need to add {yes/no} :
type yes.
Note: Don't give blank space in location path
如果您有默认 Java 设置并提供了 Java 类路径,那么您必须使用 Java Truststore 来获取 SSL 证书。
为此,您可以按照以下步骤将证书导入信任存储区:
理想情况下,路径应该是:
定位 Keytool 的路径
CMD 中的 Bin 文件夹
小路-
Java 默认信任存储的路径
现在您可以运行以下命令来查看此信任存储的内容:
keytool -list -v -keystore "C:\Program Files\Java\jre1.8.0_221\lib\security\cacerts"
注意:如果信任存储的路径中有空格,则需要在路径中使用双引号。 否则,您可以提供如下路径:
现在只需向信任存储提供密码(默认密码是:changeit):
使用 Keytool 访问信任存储
您现在可以根据需要将任何证书添加到信任商店:
JRE_HOME/bin/keytool -import -trustcacerts
-alias certAlias -file certFile
-keystore trustStoreFile
If you have default Java setup and have provided Java classpath, then you must be using Java Truststore for SSL certificates.
For this you can follow below steps to import certificates into Trust store:
Ideally the path should be:
Path to locate Keytool
Bin folder in CMD
Path-
Path to Java default Trust store
Now you can run below command to see contents of this Trust store:
keytool -list -v -keystore "C:\Program Files\Java\jre1.8.0_221\lib\security\cacerts"
Note: If your path to Trust store has spaces in it, then you need to use double quotes for the path. Else you can provide path like below:
Now just provide password to Trust Store(Default password is: changeit):
Accessing Trust store using Keytool
You can now as per your need add any certificate to the Trust store:
JRE_HOME/bin/keytool -import -trustcacerts
-alias certAlias -file certFile
-keystore trustStoreFile
您可能应该创建证书并使用 keytool 将其导入默认密钥库。 我不确定您想对您的应用程序执行什么操作,但它应该能够使用该证书。
You should probably create the certificate and import it into the default keystore using keytool. I'm not sure what you're trying to do with your application, but it should then be able to use that certificate.
在苹果电脑中
in mac