0

Trying to add certificate to java next: How to import a .cer certificate into a java keystore?

$ keytool -importcert -file ../test_cert -keystore keystore.jks -alias "Alias"

Trust this certificate? [no]:  yes
Certificate was added to keystore

Check created keystore:

$ keytool -keystore keystore.jks -list -storepass changeit
Keystore type: JKS
Keystore provider: SUN

Your keystore contains 1 entry

alias, 11.05.2018, trustedCertEntry, 
Certificate fingerprint (SHA1): A9:8B:25:AE:01:E8:92:CF:25:D6:F6:E0:8E:BC:49:87:11:8B:B5:92

Then run my java application:

./java/bin/java -Djavax.net.ssl.keyStore=keystore.jks -Djavax.net.ssl.keyStorePassword=changeit -Djavax.net.debug=all -jar Application.jar

мая 11, 2018 12:27:46 PM com.application.main.logic.classloader.JarsForPackagesContainer importJarsFromPath
INFO: JarClassLoader: import from [Application.jar]
мая 11, 2018 12:27:46 PM com.application.main.service.manager.ApplicationRuntimeManager <clinit>
INFO: Started at 2018-05-11 12:27:46

adding as trusted cert:
  Subject: CN=Go Daddy Root Certificate Authority - G2, O="GoDaddy.com, Inc.", L=Scottsdale, ST=Arizona, C=US
  Issuer:  OU=Go Daddy Class 2 Certification Authority, O="The Go Daddy Group, Inc.", C=US
  Algorithm: RSA; Serial number: 0x1be715
  Valid from Wed Jan 01 09:00:00 EET 2014 until Fri May 30 10:00:00 EEST 2031

adding as trusted cert:
  Subject: CN=RapidSSL CA, O="GeoTrust, Inc.", C=US
  Issuer:  CN=GeoTrust Global CA, O=GeoTrust Inc., C=US
  Algorithm: RSA; Serial number: 0x236d1
  Valid from Sat Feb 20 00:45:05 EET 2010 until Wed Feb 19 00:45:05 EET 2020

When application start, I can't see my cert, only anothers.

How I can add cert to java application and where I can find certs that already in use?

user2264941
  • 407
  • 1
  • 8
  • 23

1 Answers1

0

Problem was with trustcacerts, this file was inside jar archive. So I get this file from jar import my cert and then move it back and application start.

user2264941
  • 407
  • 1
  • 8
  • 23