I'm getting this error while trying to add .crt certificate to already existing keystore via terminal. I'm using Linux Ubuntu 18.04LTS with Java 11
I tried to run this command:
$ keytool -import -alias ca -file my_certificate_file_name.crt -keystore my_truststore_file_name
And also tried to run without alias:
$ keytool -import -file my_certificate_file_name.crt -keystore my_truststore_file_name
The problem was that Android uses another type of truststore named "BKS". Commands in question were related to "JKS" type of truststore.
$ keytool -importcert -v -trustcacerts -file "your_cert_file" -alias ca -keystore "your_truststore.bks" -provider org.bouncycastle.jce.provider.BouncyCastleProvider -providerpath "path_to_bcprov-jdk16-145.jar" -storetype BKS -storepass your_password
Besides, it is required to download "bcprov-jdk16-145.jar" file. You can do it from maven repo: https://mvnrepository.com/artifact/org.bouncycastle/bcprov-jdk16/1.46
After executing the command above in terminal, "BKS" truststore was successfully created.