Charles Jo
10/20/2021, 8:58 PMundermark5
10/20/2021, 11:11 PMCharles Jo
10/20/2021, 11:13 PMCharles Jo
10/20/2021, 11:14 PMCharles Jo
10/20/2021, 11:16 PMCharles Jo
10/20/2021, 11:17 PMundermark5
10/20/2021, 11:17 PMCharles Jo
10/20/2021, 11:18 PMCharles Jo
10/20/2021, 11:19 PMCharles Jo
10/20/2021, 11:23 PMundermark5
10/20/2021, 11:24 PMCharles Jo
10/20/2021, 11:30 PMundermark5
10/20/2021, 11:34 PMCharles Jo
10/20/2021, 11:36 PMCharles Jo
10/21/2021, 12:33 PMCharles Jo
10/21/2021, 12:34 PMCharles Jo
10/21/2021, 12:36 PMCharles Jo
10/21/2021, 1:18 PMundermark5
10/21/2021, 2:46 PMCharles Jo
10/21/2021, 2:48 PM@OptIn(InternalAPI::class)
private fun <TEngine : ApplicationEngine, TConfiguration : ApplicationEngine.Configuration>
CoroutineScope.embeddedServer(
factory: ApplicationEngineFactory<TEngine, TConfiguration>,
module: Application.() -> Unit
): TEngine {
val environment = applicationEngineEnvironment {
this.parentCoroutineContext = coroutineContext + parentCoroutineContext
this.log = logger
this.module(module)
connector {
port = HTTP_PORT
}
sslConnector(
sslCredentials.getKeyStore(),
keyAlias = sslCredentials.getKeyAlias(),
{sslCredentials.getAliasPassword().toCharArray()},
{sslCredentials.getAliasPassword().toCharArray()}
) {
this.port = HTTPS_PORT
this.keyStorePath = sslCredentials.getKeyStoreFile()
}
}
return embeddedServer(factory, environment)
}
undermark5
10/21/2021, 2:50 PMsslCredentials
Charles Jo
10/21/2021, 2:51 PMclass DemoSslCredentials(private val fileKeyStore: File) : SslCredentials {
override fun getKeyStoreFile() = fileKeyStore
@OptIn(InternalAPI::class)
override fun getKeyStore(): KeyStore {
return KeyStore.getInstance(KeyStore.getDefaultType()).apply {
fileKeyStore.inputStream().use {
load(it, getKeyPassword().toCharArray())
}
}
}
override fun getKeyAlias(): String {
return ALIAS
}
override fun getKeyPassword(): String {
return PASSWORD
}
override fun getAliasPassword(): String {
return PASSWORD
}
private companion object {
const val ALIAS = "alias"
const val PASSWORD = "123456"
}
}
Charles Jo
10/21/2021, 2:51 PMCharles Jo
10/21/2021, 2:52 PMCharles Jo
10/21/2021, 2:53 PMundermark5
10/21/2021, 8:40 PMconnector.keyStore.getCertificateChain
returned a null value meaning that it was unable to find the certificate chain in the keystore, what happens if you try to getEntry
before giving the keystore to Ktor?Charles Jo
10/21/2021, 8:46 PMCharles Jo
10/21/2021, 8:46 PMCharles Jo
10/21/2021, 8:58 PMundermark5
10/21/2021, 9:03 PMundermark5
10/21/2021, 9:05 PMCharles Jo
10/22/2021, 10:51 AMundermark5
10/22/2021, 1:54 PMgetCertificateChain
?Charles Jo
10/22/2021, 5:01 PMCharles Jo
10/22/2021, 5:02 PMundermark5
10/25/2021, 2:43 PMundermark5
10/25/2021, 4:16 PMCharles Jo
10/25/2021, 4:17 PM