generateCertificate

fun generateCertificate(file: File? = null, algorithm: String = "SHA1withRSA", keyAlias: String = "mykey", keyPassword: String = "changeit", jksPassword: String = keyPassword, keySizeInBits: Int = 1024, keyType: KeyType = KeyType.Server): KeyStore

Generates simple self-signed certificate with keyAlias name, private key is encrypted with keyPassword. If file is set, the key is stored in a JKS keystore in file with jksPassword.

Only for testing purposes: NEVER use it for production!

A generated certificate will have 3 days validity period and 1024-bits key strength. Only localhost and 127.0.0.1 domains are valid with the certificate.


fun KeyStore.generateCertificate(file: File? = null, algorithm: String = "SHA1withRSA", keyAlias: String = "mykey", keyPassword: String = "changeit", jksPassword: String = keyPassword, keySizeInBits: Int = 1024, caKeyAlias: String = "mykey", caPassword: String = "changeit", keyType: KeyType = KeyType.Server): KeyStore

Uses the given keystore as certificate CA caKeyAlias to generate a signed certificate with keyAlias name.

All private keys are encrypted with keyPassword. If file is set, all keys are stored in a JKS keystore in file with jksPassword.

Only for testing purposes: NEVER use it for production!

A generated certificate will have 3 days validity period and 1024-bits key strength. Only localhost and 127.0.0.1 domains are valid with the certificate.