0

I need to convert extension of ssl certificate from .cer to .bks

So, I followed this SO answer

How to convert .cer to BKS

I am using cmd

This is my input command :

keytool -importcert -v -trustcacerts -file "C:\Users\alexey.t\Downloads\my_certificates\Root_CA.cer" -alias IntermediateCA -keystore "C:\Users\alexey.t\Downloads\MyApp\app\src\res\raw\myKeystore.bks" -provider org.bouncycastle.jce.provider.BouncyCastleProvider -providerpath "C:\Users\alexey.t\Downloads\my_certificates\bcprov-ext-jdk15on-1.46.jar" -storetype BKS -storepass mysecret

Certificate already exists in system-wide CA keystore under alias <thawteprimaryrootca [jdk]>

Do you still want to add it to your own keystore? [no]:  y

Here is output I get

Certificate was added to keystore

[Storing C:\Users\alexey.t\Downloads\ElAl\app\src\res\raw\myKeystore.bks]

keytool error: java.io.FileNotFoundException: C:\Users\alexey.t\Downloads\ElAl\app\src\res\raw\myKeystore.bks (The system cannot find the path specified)
java.io.FileNotFoundException: C:\Users\alexey.t\Downloads\ElAl\app\src\res\raw\myKeystore.bks (The system cannot find the path specified)
    at java.io.FileOutputStream.open0(Native Method)
    at java.io.FileOutputStream.open(Unknown Source)
    at java.io.FileOutputStream.<init>(Unknown Source)
    at java.io.FileOutputStream.<init>(Unknown Source)
    at sun.security.tools.keytool.Main.doCommands(Unknown Source)
    at sun.security.tools.keytool.Main.run(Unknown Source)
    at sun.security.tools.keytool.Main.main(Unknown Source)

Also according to SO answer above I can use next command to check if keystore exist

keytool -list -keystore "C:\Users\alexey.t\Downloads\ElAl\app\src\res\raw\myKeystore.bks" -provider org.bouncycastle.jce.provider.BouncyCastleProvider -providerpath "C:\Users\alexey.t\Downloads\ElAl_certificates\bcprov-ext-jdk15on-1.46.jar" -storetype BKS -storepass mysecret

Here is output

keytool error: java.lang.Exception: Keystore file does not exist: C:\Users\alexey.t\Downloads\ElAl\app\src\res\raw\myKeystore.bks

So, what am I doing wrong?

user207421
  • 305,947
  • 44
  • 307
  • 483
Sirop4ik
  • 4,543
  • 2
  • 54
  • 121
  • is folder name alexey.t causing issue? can u try to move it to separate folder and try running same commands again? – Amod Gokhale Oct 22 '17 at 08:51
  • When you get a `FileNotFoundException` on an *output* file, the cause is usually that one of the target directories doesn't exist. The relevance of [tag:openssl] is exactly zero. – user207421 Oct 22 '17 at 09:02
  • 1
    @AmodGokhale "move it" - did you mean `certificate` and `BouncyCastle` files? I moved and really it is works! I put this files here `C:\LocalGit\certificate` – Sirop4ik Oct 22 '17 at 11:22
  • @AmodGokhale I am not well in ssl , but now I have to move `myKeystore.bks` file into my project. Question is : is it not going to be a problem if I move this `myKeystore.bks` file from current dir to my project `res/raw` ? – Sirop4ik Oct 22 '17 at 11:26
  • 1
    it's interesting to find out why .(dot) in path causes issue. I have submitted bug with oracle and will update this thread if get any update from them – Amod Gokhale Oct 22 '17 at 15:00
  • You are totally premature with the bug report, and it will certainly be rejected. Java doesn't have a problem with dots in filenames. What happens when you execute `dir C:\Users\alexey.t\Downloads\ElAl\app\src\res\raw` from a command prompt? – user207421 Oct 22 '17 at 23:23
  • Well you're the only one who can test it. So test it. Why are you asking me? – user207421 Oct 23 '17 at 09:25
  • @EJP Sorry I did not understand you exactly. But I mentioned above(in my question) what happens if I use this file path. Did you see? – Sirop4ik Oct 23 '17 at 10:35
  • Sure, and I asked a question about what happens when you run a specified `dir` command. What's the answer? – user207421 Oct 24 '17 at 10:17
  • @AlekseyTimoshchenko - here is response from java. dots are allowed and not an issue with keytool.. certainly looks like your local environment issue http://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8190194 – Amod Gokhale Oct 26 '17 at 11:02
  • 1
    @AmodGokhale thanks for efforts! It look like really problem with my envioriment – Sirop4ik Oct 26 '17 at 14:21
  • @MartijnPieters How can a question about `FileNotFoundException` possibly be a duplicate of a question in which that exception does not appear? Please. – user207421 Nov 09 '17 at 00:08
  • @EJP: because the *exact same answer* applied. Both questions are by the same OP, both received the exact same answer. – Martijn Pieters Nov 09 '17 at 10:50

0 Answers0