Home » Android » Adding certificate in .cer format into to .bks keystore

Adding certificate in .cer format into to .bks keystore

Posted by: admin November 1, 2017 Leave a comment

Questions:

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

Answers:

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