我找到了以下帖子,我认为我可能会有所帮助,因为我需要一种验证我的网站(我的 java 应用程序连接到的)的方法,而无需使用 java 密钥库:
http://www.mombu.com/programming/java/t-ssl-for-java-without-keystores-1366416.html
但是,我对这个世界还很陌生SSL 并且不知道我需要使用哪些文件和密码,所以如果有人能给我指出正确的方向,那就太好了。如果您没有猜到,我从 StartSSL 获得了我的 SSL 证书,该证书由 StartCom Ltd 运营/拥有/某物。这是我用来将详细信息放入密钥库的帖子:
https://forum.startcom.org/viewtopic.php?t=1390
提前致谢!
或者,我有什么办法可以使用自定义密钥库。即我将使用默认密钥库执行我需要的操作,然后将密钥库复制到 .JAR 中,以便我可以告诉我的应用程序使用 .JAR 中的密钥库而不是 Java 安装目录中的密钥库,等等...
I have found the following post, which I think I may help because I need a way of verifying my website (that my java application connects to) without having to use the java keystore:
http://www.mombu.com/programming/java/t-ssl-for-java-without-keystores-1366416.html
However, I'm quite new to the world of SSL and don't know which files and passwords I need to use, so if anybody can point me in the right direction that would be great. If you didn't guess, I got my SSL certificate from StartSSL, who are ran/owned/something by StartCom Ltd. Here is a post I used for putting the details into the keystore:
https://forum.startcom.org/viewtopic.php?t=1390
Thanks in Advance!
Alternitively, is there any way for me to use a custom keystore. i.e I'll do what I need with the default keystore and then copy the keystore into the .JAR so that I can tell my application to use the one in the .JAR instead of the one in the Java install directory, etc...
发布评论
评论(1)
是的,您可以使用
编辑:
是的,您可以指定密钥库和密钥库。属性文件中的 trustore 位置及其密码,并将属性文件加载为
myProperties.load(myProperties.getClass().getResourceAsStream("/path/to/proertyfile.properties"));
然后在代码中使用它(省略异常处理)(这不会影响任何其他应用程序):
Yes, you can create and use your own keystore for your app using the keytool utility which comes with the JDK.
Basically, a keystore is a datastore for your keys & certificates, which will be used in your app either to authenticate yourself to another entity or to digitally sign your messages or any other data.
A distinct keystore called trustore is used to keep the public key certificates of the entities you trust.
You can have these keystores placed in your classpath and specify the path in your app in code like (these are VM params which will affect all apps running in this VM):
EDIT:
Yes, you can specify the keystore & trustore locations and their passwords in a property file and load the properties file as
myProperties.load(myProperties.getClass().getResourceAsStream("/path/to/proertyfile.properties"));
and then use it in your code as (exception handling omitted)(this will not affect any other app):