0

I need to add certificate in .cer format to into BKS key store

It was described on SO here

How to convert .cer to BKS

I did next, create a dir and put inside next files :

  • keytool.exe
  • bcprov-ext-jdk15on-1.46.jar
  • Root_CA.cer

Next opening Windows PowerShell and put this command(just replacing to my data)

.\keytool -importcert -v -trustcacerts -file "path_to_cert/interm_ca.cer"
-alias IntermediateCA -keystore "path_to_your_app/res/raw/myKeystore.bks"
-provider org.bouncycastle.jce.provider.BouncyCastleProvider
-providerpath "path_to_bouncycastle/bcprov-jdk16-145.jar" -storetype BKS
-storepass mysecret

Next clicking Enter and nothing happen

Nor message of error neither something else

Just goes to next line

What am I doing wrong?

Fell free to ask

EDIT

if I type command without .\ - sings

like this keytool -importcert -v -trustcac......... , so I get this error

keytool : The term 'keytool' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + keytool -importcert -v -trustcacerts -file "C:\Users\alexey.t\Downloa ... + ~~~~~~~ + CategoryInfo : ObjectNotFound: (keytool:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException

Suggestion [3,General]: The command keytool was not found, but does exist in the current location. Windows PowerShell does not load commands from the current location by default. If you trust this command, instead type: ".\keytool". See "get-help about_Command_Precedence" for more details.


also I tried do like this

 PS C:\> C:\Users\alexey.t\Downloads\ElAl_certificates\keytool -importcert -v -trustcacerts .......

and this

PS C:> C:\Users\alexey.t\Downloads\ElAl_certificates\keytool.exe -importcert -v -trustcacerts

nothing changed

divanov
  • 6,173
  • 3
  • 32
  • 51
Sirop4ik
  • 4,543
  • 2
  • 54
  • 121
  • Did you try with the full path where keytool.exe is stored? For example `C:\temp\keytool.exe -importcert ..............` If you use `.\keytool`, it means you have set the current location to where keytool.exe is stored else you have to specify the path. – Manu Oct 17 '17 at 12:24
  • @Manu added in question. Could you take a look is it right? – Sirop4ik Oct 17 '17 at 12:38
  • Are you sure that it can be started from powershell and not from ADB (https://developer.android.com/studio/command-line/adb.html)? You also tagged this question as Android. – Manu Oct 17 '17 at 12:54
  • @Manu yes, I am using Windows PowerShell – Sirop4ik Oct 17 '17 at 13:05
  • Yes but are you sure your command has to be started from Powershell instead of ADB? – Manu Oct 17 '17 at 13:49
  • @Manu I am located `C:\` , hold Shift and click right mouse button, popup appear and I choose `open Power Shell Window here`. As far as I understand it means that my command starting from Powershell – Sirop4ik Oct 17 '17 at 13:53

1 Answers1

0

Thanks to @Amod Gokhale

So, eventually I moved my certificate and BouncyCastle files to another dir (in my case C:\LocalGit\certificate)

and I got this .bks file without issues

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Sirop4ik
  • 4,543
  • 2
  • 54
  • 121