File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes OpenSSL and Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "OpenSSL and Java" Watch "OpenSSL and Java" New topic

OpenSSL and Java

Mazen Mahmoud

Joined: Oct 25, 2007
Posts: 20

I'm trying to encrypt a serialized java file (test.ser) using OpenSSL. I've used the Runtime.getRuntime().exec function and i've passed to it the following string array : {"cmd.exe", "/c", "openssl smime -encrypt...."}
(it will create a new file : test1.ser)

everything works fine. then i've used the openssl to decrypt test1.ser. it will create new file (test2.ser). For some reasons, test2.ser is not similar to test.ser (which must not), and test2.ser cannot be used with FileInputStream and ObjectInputStream to be deserialized using the readObject function. (It will fail on the construction of ObjectInputStream).

Any help???
Joe Ess

Joined: Oct 29, 2001
Posts: 9189

Please do not post the same question more than once. It causes confusion and duplication of effort as the community tries to help everyone.
You may have better luck with an OpenSSL-oriented mailing list or forum. Try to solve using OpenSSL from the command line, then come back with java-specific concerns.
The Java API has a built-in crypto capability that may be easier to use within a Java program.

[How To Ask Questions On JavaRanch]
Mazen Mahmoud

Joined: Oct 25, 2007
Posts: 20

I was able to solve it. The problem was in the openssl command...

I agree. Here's the link:
subject: OpenSSL and Java
It's not a secret anymore!