Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should we point KeyStore and TrustStore to the same .jks file?

Tags:

java

keytool

I am using SSL handshaking to connect to a URL. To do that, i generated a .csr file and got it signed. After signing i created a my.jks file with 3 entries in it

  1. Signed Client Cert
  2. Private Key
  3. CA

I use jetty as server and i have exclusively set the keystore and truststore to the same jks file like this

-Djavax.net.ssl.keyStore=/home/keystore/my.jks
-Djavax.net.ssl.keyStorePassword=changeit
-Djavax.net.ssl.trustStore=/home/keystore/my.jks
-Djavax.net.ssl.trustStorePassword=changeit

It works fine. But is it the right way to do it? I thought the keystore should contain the client certs and private key, and the truststore should contain CA. But when i tried doing this then i get the following error.

"javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target"

Please advice on this.

like image 593
coderslay Avatar asked Feb 07 '14 16:02

coderslay


People also ask

Is truststore and keystore the same?

TrustStore is used to store certificates from Certified Authorities (CA) that verify the certificate presented by the server in an SSL connection. While Keystore is used to store private key and identity certificates that a specific program should present to both parties (server or client) for verification.

Is the .jks file keystore file?

The Java KeyStore (JKS) system is provided as part of your Java installation. Private keys and certificates for your server are stored in a keystore file.

Is jks and truststore or keystore?

JKS keystore type jks extension that are stored in the zFS file system. The JKS is referenced by the keyStore element in the server. xml configuration file. You can use a JKS for both keystores and truststores.

What are .jks files?

A Java keystore (JKS) file is a secure file format used to hold certificate information for Java applications.


1 Answers

No. A truststore contains nothing but public data: the public certificates of CAs that you trust. A KeyStore contains a private key and its certificate: your digital identity. They may even be controlled by different people. Don't conflate their functions.

like image 111
user207421 Avatar answered Oct 13 '22 11:10

user207421