wood burning stoves*
The moose likes Security and the fly likes How to know KeyManager given a keystore Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » Security
Bookmark "How to know KeyManager given a keystore" Watch "How to know KeyManager given a keystore" New topic
Author

How to know KeyManager given a keystore

Yogesh Gandhi
Ranch Hand

Joined: Dec 05, 2008
Posts: 207
Hi,

I have a keystore file which be the keystore of the server.

I am trying to test ssl connectivity to that server with the program as given on http://www.herongyang.com/JDK/SSL-Socket-Server-Example-SslReverseEchoer.html

But I am getting a NoSuchAlgorithmException on the following line :

KeyManagerFactory.getInstance("SunX509");

// Can someone please tell me what all possible values I can pass to the above method, and what can be the best possible value by looking at the output below.

When I print the details of the certificate :

D:\Yogesh>keytool -list -keystore abc.jks -v -storepass xyz

Keystore type: jks
Keystore provider: SUN

Your keystore contains 2 entries:

Alias name: trustself
Creation date: Thu Sep 29 15:26:00 IST 2011
Entry type: keyEntry
Certificate chain length: 1
Certificate[1]:
Owner: CN=#0C0C6864666362616E6B2E636F6D, OU=#0C10464F522054455354494E47204F4E4C5
9, O=#0C0E4D794F7267616E697A6174696F6E, L=#0C064D79546F776E, ST=#0C074D795374617
465, C=US
Issuer: CN=#0C0C6864666362616E6B2E636F6D, OU=#0C10464F522054455354494E47204F4E4C
59, O=#0C0E4D794F7267616E697A6174696F6E, L=#0C064D79546F776E, ST=#0C074D79537461
7465, C=US
Serial number: 23aa917a5e6203553b9784300ad8680
Valid from: Wed Sep 28 15:21:29 IST 2011 until: Mon Sep 29 15:21:29 IST 2031
Certificate fingerprints:
MD5: EC:9B:13:F6:E5:76:34:C8:F0:E6:B6:77:94:727:FB
SHA1: 1F:A0:825:B 4:FCA:01:36:71:B3:B 4:E8:F8:19:68:6D:B0:2D:04


*******************************************
*******************************************


Alias name: primatwo
Creation date: Mon Jan 16 17:46:14 IST 2012
Entry type: trustedCertEntry

Owner: CN=primauatapp.hbctxdom.com
Issuer: CN=primauatapp.hbctxdom.com
Serial number: 9ff84addac647a824198d4299a66fba3
Valid from: Mon Jan 16 12:36:34 IST 2012 until: Thu Jan 13 12:36:34 IST 2022
Certificate fingerprints:
MD5: 81:A9:3B:E5D:52:5E:2CD:42:91:20:E0:E6:C0:E0
SHA1: 42:0C5:6A:45:74:5D:7A:9D:CB:0D:F1:11:BB:7C:BC:38:F3:11:C0


*******************************************
*******************************************


Yogesh Gandhi
Ranch Hand

Joined: Dec 05, 2008
Posts: 207
When I looked at java.security file

the key manager was found to be IbmX509

and when I used this value, I was able to run the program.
Yogesh Gandhi
Ranch Hand

Joined: Dec 05, 2008
Posts: 207
You can also use the following

KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());

The java.security file lies in C:\Program Files\Java\jdk1.6.0_21\jre\lib\security or which ever java you are using.

#
# Determines the default key and trust manager factory algorithms for
# the javax.net.ssl package.
#
ssl.KeyManagerFactory.algorithm=SunX509
ssl.TrustManagerFactory.algorithm=PKIX

#
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to know KeyManager given a keystore
 
Similar Threads
certificate chain
Enable Security for JBoss + WS
Tomcat 4.1: JDK 1.4.2 Keystore issue?
SSLHandshakeException
SOAPFaultException: Policy requires confidentialityenc key : 0