2ways ssl not working: bad certificate

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nickyeng
    Contributor
    • Nov 2006
    • 252

    #1

    2ways ssl not working: bad certificate

    I created one simple test java application to connect to a web service over HTTP/SSL.

    The webservice provider given us 3 certificates for testing purpose:
    1. Client Test Certificate with private key: abctest.p12
    2. Client Test Certificate with public key: abctest.cer
    3. Provider Test Certificate with public key: abc.cer

    I've added these 3 certificate into "cacerts" truststore using java 'keytool'.
    for 3 certificates, i created 3 different alias name: abcp12, abctest & abc in "cacerts" truststore.

    And then I test the program, for 1way SSL connection, my program works fine(request to them, they return response).

    But when i try to use 2 ways SSL connection, my program does not work. It gives me this error: "received fatal error: bad_certificate "

    I've googled but doesn't help me at all.
    I've added 3 certificates into my truststore.
    I checked the list with command "keytool -list -v" and all the certs are there.
    1way ssl is working but 2ways ssl is NOT working with receiving bad certificate error.

    Can anyone please help me? Why bad certificate? Something wrong with the way I add the cert into truststore file?
    Last edited by Niheel; May 21 '10, 04:39 AM. Reason: spelling, punctuation
  • George Denholm
    New Member
    • Mar 2011
    • 1

    #2
    Too late for Nick I guess, but I have been experiencing the same problem and in my case was fixed by adding the following lines before I set up the connection

    System.setPrope rty("javax.net. ssl.keyStoreTyp e", "JKS");
    System.setPrope rty("javax.net. ssl.keyStore", "/usr/java/jre1.6.0_21/lib/security/cacerts");
    System.setPrope rty("javax.net. ssl.keyStorePas sword", "changeit") ;
    System.setPrope rty("javax.net. ssl.trustStoreT ype", "JKS");
    System.setPrope rty("javax.net. ssl.trustStore" , "/usr/java/jre1.6.0_21/lib/security/cacerts");
    System.setPrope rty("javax.net. ssl.trustStoreP assword", "changeit") ;

    I suspect the first 3 lines made the difference - by default the JVM knows the trust store config, and can do 1 way, but is not aware of a certificate key store and so does not supply a valid certificate to the server & 2 way handshake fails.

    Comment

    Working...