I want to create jks file (keystore) file programmatically (some script on Java/Kotlin JVM) without using Android Studio. Is it possible?
I have a little code to create this file but how fill all the needed data to that key?
fun createJksFile() {
val keyFilePassword = "test"
val keyAlias = "test"
val keyPassword = "test"
val keyValidity = "100"
val CertificateFirstandLastName = "Test"
val CertificateOrganizationalUnit = "Test"
val CertificateOrganization = "Test"
val CertificateCityorLocality = "US"
val CertificateStateorProvince = "US"
val CertificateCountryCode = "US"
val ks = KeyStore.getInstance(KeyStore.getDefaultType())
val password = keyFilePassword.toCharArray()
ks.load(null, password)
// TODO: how to set all needed data?
FileOutputStream(File(projectDir, "_test_key.jks")).use { fos ->
ks.store(fos, password)
}
}
