简体   繁体   English

tomcat 将证书添加到信任库

[英]tomcat add certificate to truststore

I have java web application deployed on kuberneties cluster and runs on tomcat (tomcat:9.0.37) container.我在 kuberneties 集群上部署了 java web 应用程序,并在 tomcat (tomcat:9.0.37) 容器上运行。 my application connect with ABC API and in order to connect to ABC API i need to have ABC API certificate in my trust store.我的应用程序与 ABC API 连接,为了连接到 ABC API,我需要在我的信任库中有 ABC API 证书。 for my local testing i am able to use keytool command to add the certificate to my JRE cecart like below command keytool -importcert -alias startssl -keystore /usr/local/openjdk-8/jre/lib/security/cacerts -storepass changeit -file ABC.cert but i want to know is this the only way to add cert to trust store or some other way i can add cert in trust store.对于我的本地测试,我可以使用 keytool 命令将证书添加到我的 JRE cecart 中,如下所示的命令keytool -importcert -alias startssl -keystore /usr/local/openjdk-8/jre/lib/security/cacerts -storepass changeit -file ABC.cert但我想知道这是将证书添加到信任存储的唯一方法还是我可以在信任存储中添加证书的其他方式。

First, if you want to have a different default truststore for SSL/TLS than for other purposes, but still JRE-wide, you can use (JRE)/lib/security/jssecacerts instead of (JRE)/lib/security/cacerts .首先,如果您希望SSL/TLS 的默认信任库其他目的不同,但仍适用于 JRE,则可以使用(JRE)/lib/security/jssecacerts而不是(JRE)/lib/security/cacerts Unlike cacerts which is filled by the JRE package or platform with numerous common CAs, jssecacerts starts out empty;与由 JRE 包或平台填充的具有众多常见 CA 的 cacerts 不同,jssecacerts 一开始是空的; if you want any of the common CAs, you must add them explicitly, optionally by copying from cacerts one-by-one or just copying the whole cacerts file.如果您想要任何常见的 CA,则必须明确添加它们,可以选择从 cacerts 中逐个复制或仅复制整个 cacerts 文件。 I don't know if you will count this as 'other' or not.我不知道你会不会把这算作“其他”。

Second, you can change the default truststore for a JVM instance with system properties javax.net.ssl.trustStore* ;其次,您可以使用系统属性javax.net.ssl.trustStore*更改JVM 实例的默认信任库; see the documentation (a few pages into the second table, Table 8-3) and more specifically this subordinate section .请参阅文档(第二个表中的几页,表 8-3),更具体地说是这个从属部分

Third, for a specific connection (or sometimes groups of connections) within the JVM, you can specify a different truststore in the code that creates the connection;第三,对于 JVM 中的特定连接(或有时是连接组),您可以在创建连接的代码中指定不同的信任库; the method varies with different means of creating the connection, which you didn't identify.该方法因创建连接的不同方式而异,您没有确定。 Using SSLSocket or SSLEngine directly is one thing;直接使用SSLSocketSSLEngine是一回事; java.net.UrlConnection and java.net.http.HttpClient (in j11+) are different; java.net.UrlConnectionjava.net.http.HttpClient (在 j11+ 中)是不同的; middleware like Apache or many others are different again.像 Apache 或许多其他中间件又有所不同。 Rather than spend hours trying to write all possible options, most of which would be wasted, I'll let you ask again if you want this.与其花几个小时试图写出所有可能的选项,其中大部分都会被浪费掉,我会让你再问一次你是否想要这个。 In the StackOverflow mantra, "show your code".在 StackOverflow 的口头禅中,“展示你的代码”。

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

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