0

I'm trying to test a HTTPS SSL connection from my local machine as I'm facing some issues implementing the same in my server.

Steps I followed

  1. I downloaded the third party HTTPS server SSL certificate from the browser (DER format) and I see its issued by Comodo RSA

  2. I tried to import the key as .jks with the command from the command prompt, but it failed with the error 'certificate.jks file not found'/ keytool -importcert -alias testCert -file c:\desktop\testCert.cer -keystore "C:\Program Files\Java\jre1.6.0\lib\security\certificate.jks" -storepass changeit

  3. So I googled and created the keystore with the command

    keytool -genkey -alias mykey -keystore "C:\Program Files\Java\jre1.6.0\lib\security\certificate.jks"

  4. And now I executed the same command (step 2), which ran successfully. I could even list and see the certificate in certificate.jks file.

  5. But when I try to access the certificate.jks in my java program as the keystore, it fails with the error 'file not found - certificate.jks'.

        KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
        ks.load(new FileInputStream ("C:/Program Files/Java/jre1.6.0/lib/security/certificate.jks"), passw );
    

Please clarify what am I doing wrong here.

Also, I'm trying not to use cacerts since it gets refreshed automatically in my server. And I beleive if I create my own .jks, it won't get refereshed. Please help.

Thanks

tsjo
  • 3
  • 4
  • 1
    Is your path correct? there is more than one space between Program and Files? – titogeo May 08 '17 at 15:21
  • Yes, it is,that was a typo. Thanks – tsjo May 08 '17 at 17:32
  • This code should be working - just tested it here. FileNotFoundException: "if the file does not exist, is a directory rather than a regular file, or for some other reason **cannot be opened for reading**". Maybe try to put the file in another directory.. – user85421 May 08 '17 at 21:01

0 Answers0