Hello, I want to create a localhost HTTPS server w...
# ktor
a
Hello, I want to create a localhost HTTPS server with self-signed certificate bundled. To build distribution I use
installDist
. To setup an embedded server
.conf
is used. I created a
.jks
file and filled a config:
Copy code
security {
    ssl {
        keyStore = "./backend/ktor/embedded/resources/keyal.jks"
        keyAlias = "keyal"
        keyStorePassword = "baaar"
        privateKeyPassword = "fooo"
    }
}
How to bundle a ktor server with
jks
to run it on another computer?
s
I can think of two options here • move the engine config to code and create the keystore dynamically during bootstrap or load from resource file
Copy code
val keyStore = buildKeyStore {
        certificate("sampleAlias") {
            password = "foobar"
            domains = listOf("127.0.0.1", "0.0.0.0", "localhost")
        }
    }

 sslConnector(
            keyStore = keyStore,...
  )
• When server startup create the keystore file (once) and store in $HOME directory. The configure the keystore path as
keystore = ${HOME}/keyal.jks
. Here also you can use the buildKeyStore{} builder function to create the keystore file. Wish ktor allowed resource path in the config file.