简体   繁体   English

如何使 java 应用程序的信任库保持最新?

[英]How to keep the truststore of a java application up-to-date?

I am currently working towards enforcing SSL trust for all outward HTTPS communication in my java application, including disallowing self-signed certificates in the hardened mode.我目前正在努力在我的 java 应用程序中对所有向外的 HTTPS 通信强制执行 SSL 信任,包括在强化模式下禁止自签名证书。

However, I am wondering how and if the SSL Trust is always trustable.但是,我想知道 SSL 信任如何以及是否始终值得信赖。 Can you help me understand the below details about truststores in Java?您能帮我了解 Java 中有关信任库的以下详细信息吗? The SSL trust solely depends on the contents of our trust store (Trust anchors which we base the trust on) SSL 信任完全取决于我们信任存储的内容(我们基于信任的信任锚)

  1. Is the default java certificate store, kept updated automatically ie if a new CA comes up (Unless a Java upgrade package is installed)?默认的 java 证书存储是否会自动更新,即如果出现新的 CA(除非安装了 Java 升级 package)?
  2. Does trusted root CA information in trust stores need a constant update to maintain SSL security?信任存储中的受信任根 CA 信息是否需要不断更新以维护 SSL 安全性?
  1. The Java trust store is only updated when you update the JRE. Java 信任库仅在您更新 JRE 时更新。 If you want do add new CA certificates you need to do this in your own.如果您想添加新的 CA 证书,您需要自己执行此操作。 In my experience this is not necessary for public CAs if you keep your JRE up to date.根据我的经验,如果您使 JRE 保持最新,那么公共 CA 就不需要这样做。
  2. No, you do not need to update the information.不,您不需要更新信息。 In the worst case you have a too certificates in the trust store and you cannot connect to a server (which is not a security issue).在最坏的情况下,您在信任库中有一个证书,并且您无法连接到服务器(这不是安全问题)。
  1. As far as I know the default java cacert file is updated only by package update/upgrade.据我所知,默认的 java cacert 文件仅由 package 更新/升级来更新。

  2. Constant update is needed because CA root certificates expire or get revoked and must be removed from cacertfile.需要不断更新,因为 CA 根证书过期或被吊销,必须从 cacertfile 中删除。 On the other side new CA root certificates are issued and must be included.另一方面,新的 CA 根证书被颁发并且必须包括在内。 But this update relies on 1.但是这个更新依赖于1。

Digging a bit deeper:深入挖掘:

If you are seting up HTTPS on your server side than:如果您在服务器端设置 HTTPS 比:

You need a private key and a certificate signed by any official certification authority like Entrust, Baltimore CyperTrust (or create a self-signed one).你需要一个私钥和一个由任何官方证书颁发机构签署的证书,如 Entrust、Baltimore CyperTrust(或创建一个自签名证书)。 You have to setup a java keystore containing the private key together with the signed certificate.您必须设置一个包含私钥和签名证书的 java 密钥库。 The certificate itselve has a limited validity and must be renewed before expiration what must be monitored by you.证书本身的有效期是有限的,必须在到期前更新,您必须对其进行监控。 On renewal the CA takes care to use always a CA root certificate which is valid as long as the renewed one.更新时,CA 会注意始终使用与更新后的证书一样有效的 CA 根证书。

A client connecting to your server receives on SSL handshake your server certificate and verifies it against it's truststore which in case of default configuration and java resides in jre-xyz/lib/security/cacerts.连接到您的服务器的客户端在 SSL 上收到与您的服务器证书握手并根据其信任库验证它,在默认配置和 java 位于 jre-xyz/lib/security/cacerts 的情况下。 This file is updated on every java update and you can rely on it's actuality.此文件在每次 java 更新时都会更新,您可以依赖它的实际情况。

If you use additionally certificate based client authentication it's up to you to keep the required client certificates up to date.如果您使用额外的基于证书的客户端身份验证,则由您来确保所需的客户端证书是最新的。 Usually your mates send you a copy of their certificate on renewal before they expire.通常,您的伴侣会在证书到期前向您发送一份更新证书的副本。

Alternately you can implement only the CA root certificate of your clients.或者,您可以仅实施客户端的 CA 根证书。 In that case you have less effort to keep the truststore up to date.在这种情况下,您可以减少使信任库保持最新的工作量。 The backdraw is that you have less opportunities of client verification.缺点是您获得客户验证的机会较少。

If you are on client side than:如果您在客户端,则:

A client in default configuration verifies a server certificate against the cacert file which comes with Java.默认配置中的客户端根据 Java 附带的 cacert 文件验证服务器证书。

Aside the default configuration - in case you will trust only some specific server - you are in charge to setup a truststore and to keep it up to date.除了默认配置 - 如果您只信任某些特定服务器 - 您负责设置信任库并使其保持最新。 This trustsore is equivalend to the one described above for client authentication but contains server's stuff.此信任库等同于上述用于客户端身份验证的信任库,但包含服务器的内容。

And at least, if you need client authentication yo have to set up a client keystore which is equivalent to the above explained server keystore but keeps client's stuff.至少,如果您需要客户端身份验证,您必须设置一个客户端密钥库,该密钥库等效于上述服务器密钥库,但保留客户端的内容。

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

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