https://kotlinlang.org logo
#ktor
Title
# ktor
j

John O'Reilly

09/10/2020, 9:33 AM
Anyone have experience running ktor-server on Android using sslConnector? Tried to use AndroidKeyStore without luck. (stack trace in thread)
Copy code
09-10 03:54:22.042  4650  4650 E neat    : javax.net.ssl.SSLException: failed to initialize the server-side SSL context
09-10 03:54:22.042  4650  4650 E neat    :      at io.netty.handler.ssl.JdkSslServerContext.newSSLContext(JdkSslServerContext.java:288)
09-10 03:54:22.042  4650  4650 E neat    :      at io.netty.handler.ssl.JdkSslServerContext.<init>(JdkSslServerContext.java:247)
09-10 03:54:22.042  4650  4650 E neat    :      at io.netty.handler.ssl.SslContext.newServerContextInternal(SslContext.java:465)
09-10 03:54:22.042  4650  4650 E neat    :      at io.netty.handler.ssl.SslContextBuilder.build(SslContextBuilder.java:571)
09-10 03:54:22.042  4650  4650 E neat    :      at io.ktor.server.netty.NettyChannelInitializer.<init>(NettyChannelInitializer.kt:73)
09-10 03:54:22.042  4650  4650 E neat    :      at io.ktor.server.netty.NettyApplicationEngine.<init>(NettyApplicationEngine.kt:103)
09-10 03:54:22.042  4650  4650 E neat    :      at io.ktor.server.netty.Netty.create(Embedded.kt:14)
09-10 03:54:22.042  4650  4650 E neat    :      at io.ktor.server.netty.Netty.create(Embedded.kt:12)
09-10 03:54:22.042  4650  4650 E neat    :      at io.ktor.server.engine.EmbeddedServerKt.embeddedServer(EmbeddedServer.kt:79)
09-10 03:54:22.042  4650  4650 E neat    :      at io.ktor.server.engine.EmbeddedServerKt.embeddedServer$default(EmbeddedServer.kt:77)
...
09-10 03:54:22.042  4650  4650 E neat    : Caused by: java.security.KeyStoreException: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
09-10 03:54:22.042  4650  4650 E neat    :      at com.android.org.bouncycastle.jcajce.provider.keystore.bc.BcKeyStoreSpi.engineSetKeyEntry(BcKeyStoreSpi.java:681)
09-10 03:54:22.042  4650  4650 E neat    :      at java.security.KeyStore.setKeyEntry(KeyStore.java:1179)
09-10 03:54:22.042  4650  4650 E neat    :      at io.netty.handler.ssl.SslContext.buildKeyStore(SslContext.java:1102)
09-10 03:54:22.042  4650  4650 E neat    :      at io.netty.handler.ssl.SslContext.buildKeyManagerFactory(SslContext.java:1274)
09-10 03:54:22.042  4650  4650 E neat    :      at io.netty.handler.ssl.SslContext.buildKeyManagerFactory(SslContext.java:1263)
09-10 03:54:22.042  4650  4650 E neat    :      at io.netty.handler.ssl.JdkSslServerContext.newSSLContext(JdkSslServerContext.java:266)
@hhariri @e5l do know at least if this should be possible before we invest too much more time trying to get this working?
e

e5l

09/10/2020, 10:08 AM
Hey, I didn't check
netty
server on the
Android
. @cy could you take a look?
c

cy

09/10/2020, 5:08 PM
Looks like it fails due to some key misconfiguration. Need to investigate.
Btw, we never tried netty ssl on Android
Netty itself should work but need to check requitements
j

John O'Reilly

09/10/2020, 5:11 PM
thanks @cy
@cy Do you think it would make a difference to use a different engine instead of netty here?
we tried
Jetty
but now get
Copy code
9-11 11:27:10.815  8461  8461 E neat    : java.lang.NoClassDefFoundError: Failed resolution of: Ljavax/naming/ldap/LdapName;
09-11 11:27:10.815  8461  8461 E neat    :      at org.eclipse.jetty.util.ssl.X509.<init>(X509.java:90)
09-11 11:27:10.815  8461  8461 E neat    :      at org.eclipse.jetty.util.ssl.SslContextFactory.load(SslContextFactory.java:346)
tried
CIO
and get
Copy code
UnsupportedOperationException: HTTPS is not supported
looks like the
LdapName
error was caused by certificate config issue ....got passed that and seeing if we can get this working with Jetty
@cy did you by chance find anything more about this i.e. ability to use Android Keystore when using netty?
38 Views