0

I have a webapp deployed wich uses a jks loaded from a database.

They work perfect on the server but when I run this app on my pc I get an error "Invalid keystore format" at this code:

public static KeyStore loadKeystore(InputStream is, String password,String type)
            throws NoSuchAlgorithmException, CertificateException, IOException,
            KeyStoreException {

        KeyStore ks = KeyStore.getInstance(type);
        ks.load(is, password.toCharArray()); //<--error thrown here

        return ks;
    }

Both server and I had JAVA 1.6, I installed JAVA 8 on my pc but later returned to 1.6 (changed w7 enviromentals). Could this have something to do? No code was changed.

Im running the webapp from eclipse with this in .ini: C:/Program Files (x86)/Java/jdk1.6.0_45/bin

Any idea on what I can try to detect the issue or get it working again?

Thanks

/how do i read/write/ --Insert

INSERT INTO te_keystores (fields, keystore) VALUES 
(fields, 
decode('/u3+7QAAAAIAAAABAAAAAQA...etc','base64')); 

--Read with a select field using hibernate

<property name="keystore"       type="org.springframework.orm.hibernate3.support.BlobByteArrayType" 
     lazy="true">
     <column name="KEYSTORE" />
 </property>
rogerbax
  • 33
  • 5
  • Perhaps I'm looking at an encoding problem? – rogerbax Feb 22 '16 at 20:44
  • How is the keystore stored in the database? – Frank Feb 23 '16 at 08:22
  • in postgre, on a bytea field – rogerbax Feb 23 '16 at 14:18
  • And how is it read? Can you post the code (write and read)? – Frank Feb 23 '16 at 15:09
  • --Insert INSERT INTO te_keystores (fields, keystore) VALUES (fields, decode('/u3+7QAAAAIAAAABAAAAAQA...etc','base64')); --Read with a select field using hibernate – rogerbax Feb 23 '16 at 15:19
  • OK, if I read this correctly you decode your base64 encoded keystore before writing it into the database and there's no dedicated encoding when reading from the db. I think your first idea is right. You have an encoding problem. I suggest to write the base64 encoded data into the db, read it as base64 encoded data and decode it when reading. – Frank Feb 23 '16 at 15:43

0 Answers0