在Tomcat中配置Truststore [英] Configure Truststore in Tomcat

查看:851
本文介绍了在Tomcat中配置Truststore的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个当前在Tomcat 7(Windows)上运行的Java servlet并连接到SQL Server数据库。我现在需要加密此连接,并且我在密钥库中有一个公钥SSL证书。但显然我必须为Truststore配置系统属性并将truststore设置为密钥库。

I have a Java servlet currently running on Tomcat 7 (Windows) and connects to a SQL Server database. I now need to encrypt this connection and I have a public Key SSL certificate in a keystore. But apparently I have to configure a system property for a "Truststore" and have the truststore set to the keystore.

密钥库位置为C:\SSLKeys \\\ appkeystore .key,根据我的发现,我必须使用以下内容设置Truststore;

The keystore location is C:\SSLKeys\appkeystore.key and from what I have found I have to set the Truststore up with the following;

Djavax.net.ssl.trustStore = C:\ SSLKeys \ appkeystore .key
Djavax.net.ssl.trustStorePassword = appkeystorePassword

Djavax.net.ssl.trustStore=C:\SSLKeys\appkeystore.key Djavax.net.ssl.trustStorePassword=appkeystorePassword

但我该怎么设置这些呢?我在命令行中尝试过,但似乎没有用。我不想在Java中对它们进行硬编码,因为我需要它们是可配置的。

But how do I set these please? I have tried it in the command line but that doesn't seem to work. I don't want to hard code these in the Java as I need them to be configurable.

这些可以在Tomcat的Catalina.bat文件中设置吗?如果是这样,我把文件放在哪里?

Can these be set in the Catalina.bat file in Tomcat? If so where in the file do I put the command?

推荐答案

我想我可能已经找到了,或者至少有一种方法这样做。有人请告诉我是否有更好的方法来处理这个问题。在Tomcat\bin文件夹中,我在catalina.bat文件中创建了一个setenv.bat文件,并在那里我声明了两个Java选项属性;

I think I may have found how, or at least one way of doing this. Someone please tell me if there is a better way of processing this. In the Tomcat\bin folder, where the catalina.bat file is I created a setenv.bat file and in there I declared the two Java option properties for;

set JAVA_OPTS="-Djavax.net.ssl.trustStore=C:\path\to\keystore.key" "-Djavax.net.ssl.trustStorePassword=************"

显然当启动Tomcat时,它会启动catalina.bat文件并且catalina.bat文件确定是否存在setenv.bat文件,如果存在则运行此文件以设置Java选项。

Apparently when Tomcat is started it initiates the catalina.bat file and the catalina.bat file determines if a setenv.bat file exists and if so runs this file to set the Java options.

如果我错了,请有人纠正我建议任何更好的方法。虽然Tomcat被设置为Windows服务,但上面的选项通过tomcatXw.exe输入以启动Tomcat控制台,并且选择了Java选项卡。

Again someone please correct me if I am wrong and advise of any better way of doing this. Although apparently where Tomcat is set up as a Windows service the options above are input through the tomcatXw.exe to initiate the Tomcat console and the Java tab is selected.

这篇关于在Tomcat中配置Truststore的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆