简体   繁体   English

我们可以从 JRE 的“cacerts”文件中导出证书并将其导入更高的 JRE 版本吗?

[英]Can we export certificates from JRE's "cacerts" file and import it to higher JRE version?

I am using a JRE 8u211.我正在使用 JRE 8u211。 And i have few certificates added in cacerts.而且我在 cacerts 中添加了很少的证书。 But when I upgrade JRE to 8u261, those certificates are not getting imported.但是当我将 JRE 升级到 8u261 时,这些证书没有被导入。 So now i want to programmatically export the required certificates from cacerts file of 8u211 using the alias names and then import those certificates to the cacerts file of 8u261.所以现在我想使用别名以编程方式从 8u211 的 cacerts 文件中导出所需的证书,然后将这些证书导入到 8u261 的 cacerts 文件中。

Is this even possible or supported?这甚至可能或支持吗?

Thanks in advance.提前致谢。

Certificate is just a data .证书只是一个数据 You definitely can export it to the file, and import that data into some other file.您绝对可以将其导出到文件中,然后将该数据导入到其他文件中。

If you just want to import one truststore file's data into another, you can directly make use of buffer without storing data into an intermediary file:如果您只想将一个 truststore 文件的数据导入另一个,您可以直接使用 buffer 而不将数据存储到中间文件中:

keytool.exe -importkeystore -srckeystore %JAVA_HOME%\lib\security\cacerts -destkeystore \your\file\path\filename
            -deststoretype jks
            -srcstorepass changeit -deststorepass changeit
            -v -noprompt

However, you can also do these two operations one by one:不过,你也可以一一进行这两个操作:

  1. To export the certificate:要导出证书:

     keytool -export -alias alias_name -keystore path_to_keystore_file -rfc -file path_to_certificate_file
  2. To import the certificate:要导入证书:

     keytool -importcert -alias alias_name -file path_to_certificate_file -keystore truststore_file

More on this can be read here , here and here .可以在此处此处此处阅读有关此内容的更多信息

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

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