avoronsky / AndroidHttpServer

Android Http Server sample app
11 stars 1 forks source link

connector.keyStore.getCertificateChain(connector.keyAlias) NPE #1

Open wangsuicheng opened 3 years ago

wangsuicheng commented 3 years ago

I test verison 1.6.2, cause the above problems Caused by: java.lang.NullPointerException: connector.keyStore.getCertificateChain(connector.keyAlias) must not be null

kambojumang commented 2 years ago

I am testing this demo getting this issue:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.voronsky.androidhttpserver/com.voronsky.androidhttpserver.MainActivity}: java.io.FileNotFoundException: /storage/emulated/0/Download/demo_keystore.bks: open failed: ENOENT (No such file or directory) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3616) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3780) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2251) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:233) at android.app.ActivityThread.main(ActivityThread.java:8068) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:631) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:978) Caused by: java.io.FileNotFoundException: /storage/emulated/0/Download/demo_keystore.bks: open failed: ENOENT (No such file or directory) at libcore.io.IoBridge.open(IoBridge.java:492) at java.io.FileInputStream.(FileInputStream.java:160) at com.voronsky.androidhttpserver.DemoSslCredentials.getKeyStore(DemoSslCredentials.kt:18) at com.voronsky.androidhttpserver.HttpServer$embeddedServer$environment$1.invoke(HttpServer.kt:56) at com.voronsky.androidhttpserver.HttpServer$embeddedServer$environment$1.invoke(HttpServer.kt:15) at io.ktor.server.engine.ApplicationEngineEnvironmentBuilder.build(ApplicationEngineEnvironment.kt:104) at io.ktor.server.engine.ApplicationEngineEnvironmentKt.applicationEngineEnvironment(ApplicationEngineEnvironment.kt:44) at com.voronsky.androidhttpserver.HttpServer.embeddedServer(HttpServer.kt:46) at com.voronsky.androidhttpserver.HttpServer.createServer(HttpServer.kt:29) at com.voronsky.androidhttpserver.HttpServer.(HttpServer.kt:18) at com.voronsky.androidhttpserver.MainActivity.createAndStartServer(MainActivity.kt:54) at com.voronsky.androidhttpserver.MainActivity.onCreate(MainActivity.kt:24) at android.app.Activity.performCreate(Activity.java:8006) at android.app.Activity.performCreate(Activity.java:7990) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1329) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3589) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3780)  at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)  at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)  at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2251)  at android.os.Handler.dispatchMessage(Handler.java:106)  at android.os.Looper.loop(Looper.java:233)  at android.app.ActivityThread.main(ActivityThread.java:8068)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:631)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:978)  Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory) at libcore.io.Linux.open(Native Method) at libcore.io.ForwardingOs.open(ForwardingOs.java:166) at libcore.io.BlockGuardOs.open(BlockGuardOs.java:254) at libcore.io.ForwardingOs.open(ForwardingOs.java:166) at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:7929) at libcore.io.IoBridge.open(IoBridge.java:478) at java.io.FileInputStream.(FileInputStream.java:160)  at com.voronsky.androidhttpserver.DemoSslCredentials.getKeyStore(DemoSslCredentials.kt:18)  at com.voronsky.androidhttpserver.HttpServer$embeddedServer$environment$1.invoke(HttpServer.kt:56)  at com.voronsky.androidhttpserver.HttpServer$embeddedServer$environment$1.invoke(HttpServer.kt:15)  at io.ktor.server.engine.ApplicationEngineEnvironmentBuilder.build(ApplicationEngineEnvironment.kt:104)  at io.ktor.server.engine.ApplicationEngineEnvironmentKt.applicationEngineEnvironment(ApplicationEngineEnvironment.kt:44)  at com.voronsky.androidhttpserver.HttpServer.embeddedServer(HttpServer.kt:46)  at com.voronsky.androidhttpserver.HttpServer.createServer(HttpServer.kt:29)  at com.voronsky.androidhttpserver.HttpServer.(HttpServer.kt:18)  at com.voronsky.androidhttpserver.MainActivity.createAndStartServer(MainActivity.kt:54)  at com.voronsky.androidhttpserver.MainActivity.onCreate(MainActivity.kt:24)  at android.app.Activity.performCreate(Activity.java:8006)  at android.app.Activity.performCreate(Activity.java:7990)  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1329)  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3589)  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3780)  at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)  at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)  at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2251)  at android.os.Handler.dispatchMessage(Handler.java:106)  at android.os.Looper.loop(Looper.java:233)  at android.app.ActivityThread.main(ActivityThread.java:8068)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:631)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:978) 

avoronsky commented 2 years ago

@wangsuicheng @kambojumang hello guys! You need to generate your certs to make it work