简体   繁体   中英

java trust unix certificate store

I have added a crt to /etc/pki/ca-trust/source/anchors so the server certificate can trusted by ssl clients. So, for example, when I curl https://<server> the certificate is trusted automatically.

Is there any way to make a java application to trust the certificates installed on the system?

Is the only way to make it works in java adding the certificate to the jvm truststore?

Regards

I don't know any out of the box solutions for that. I think there're multiple ways to reach your goal:

  1. Write a class to sync you defined trust store and the cert directory
  2. Write an own TrustManager implementation which is based on the cert directory

将其导入JRE中的cacerts文件,如果有JDK,则导入JDK。

Import the certs in cacert file


Below is the path
C:\\Program Files (x86)\\Java\\jre1.8.0_121\\bin

use this code to import (assuming that your *.cer file name is abc.cer, you need to paste the abc.cer file in the bin folder then using the same path of bin in CMD run the below code)
keytool -import -file abc.cer -alias anyName -keysotre cacert -trustcacerts

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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