F
Fritz Bayer
Hi,
I generated a keystore file with the java keytool. Now I would like to
import the data via copy and paste into my java source code and store
the data as a String.
To achieve this I did the following steps:
1. native2ascii -encoding utf-8 keystorefile iso8859_keystore_data.txt
2. Replace " in the iso8859_keystore_data.txt with \"
3. Replace newlines in the iso8859_keystore_data.txt with \n
4. Copy and paste the data into my program.
When I load the keystore using " trustStore.load(new
ByteArrayInputStream(copyAndPastedString.getBytes("utf-8")),
password);" I get an exception saying that the Format is invalid. So
somewhere along the conversion the data get altered.
For all the IO pros out there I have some questions, which I think
will help me get closer to the solution of the problem.
1. Are the keystore files created with the java keytool actually
encoded in utf-8? Which encoding is used - I assumed its utf-8...
2. Generally speaking should I use the string "utf-8" or "utf8" in my
java program, when for example using String.getBytes(String encoding)
?
3. Do you know a program, which reads a utf-8 encoded file and writes
the data to a new file thereby producing only unicode escapes ? (This
would save step 2 and 3, which are error prone)
Fritz
I generated a keystore file with the java keytool. Now I would like to
import the data via copy and paste into my java source code and store
the data as a String.
To achieve this I did the following steps:
1. native2ascii -encoding utf-8 keystorefile iso8859_keystore_data.txt
2. Replace " in the iso8859_keystore_data.txt with \"
3. Replace newlines in the iso8859_keystore_data.txt with \n
4. Copy and paste the data into my program.
When I load the keystore using " trustStore.load(new
ByteArrayInputStream(copyAndPastedString.getBytes("utf-8")),
password);" I get an exception saying that the Format is invalid. So
somewhere along the conversion the data get altered.
For all the IO pros out there I have some questions, which I think
will help me get closer to the solution of the problem.
1. Are the keystore files created with the java keytool actually
encoded in utf-8? Which encoding is used - I assumed its utf-8...
2. Generally speaking should I use the string "utf-8" or "utf8" in my
java program, when for example using String.getBytes(String encoding)
?
3. Do you know a program, which reads a utf-8 encoded file and writes
the data to a new file thereby producing only unicode escapes ? (This
would save step 2 and 3, which are error prone)
Fritz