• Post Reply Bookmark Topic Watch Topic
  • New Topic

PKCS12 Certificate and Keystore  RSS feed

Janaki Raju
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am using a PKCS12 certificate file. I am running java 1.5

The following is the code that I use to create a SSL socket and send data.

SSLSocketFactory factory = null;
try {
SSLContext ctx;
KeyManagerFactory kmf;
KeyStore ks;

char[] passphrase = this.keyStorePassword.toCharArray();

ctx = SSLContext.getInstance("SSL");
kmf = KeyManagerFactory.getInstance(keyManagerInstance);

if (keyStoreInstance.length() > 0) {
ks = KeyStore.getInstance(this.keyType, keyStoreInstance);
} else {
ks = KeyStore.getInstance(this.keyType);

ks.load(new FileInputStream(this.keyStore),passphrase);
kmf.init(ks, passphrase);

factory = ctx.getSocketFactory();
} catch (Exception e) {
throw new IOException(e.getMessage());
SSLSocket socket = (SSLSocket)factory.createSocket(path.getHost(),path.getPort());
//Connect using Socket
// This is followed by code to write out the data and then read in the response.

When I run this code, I get an exception - " SSL HandShake Exception - No trusted certificate found". I am not sure how to proceed beyond this. Is there a way I can add the certificate to the keystore? I have tried importing the file to the java truststore- does not seem to work.


  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!