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

Adriano Celentano

10/11/2019, 8:39 AM
Im trying to make ktor server running inside an Android App. The Problem is i also need to provide ssl. I generated a self signed certificate with .jks I could not generate it from android and i cant load it from android assets. It seems like Android is not supporting jks. Is there another self signed certificate Type supported by ktor ?
j

Jorge R

10/11/2019, 8:43 AM
is it mandatory communication through android? dont you have a different way to work to place a different architecture?
in a regular arch Im setting an Nginx to handle SSL certs
a

Adriano Celentano

10/11/2019, 8:45 AM
Our requiremt is to serve a rest enpoint someone can call to Trigger calls to an Android App and get a response
So another solution we thought of to run the Server not on Android but as a Middleware which communicates with the App via websockets
@Jorge R u think nginx would Help in my case?
j

Jorge R

10/11/2019, 8:47 AM
trigger calls to android app
that looks like going completely the other way around how the regular arch works for Android as a frontend
what I have: (Android) Users -> Nginx -> Ktor backend
Android has many peculiarities and restrictions coming from the platform itself
so this could be a deal breaker for you, as it is not intended to be use mainly as a server
a

Adriano Celentano

10/11/2019, 8:50 AM
Ah no my case Android should be the Server ^^
It can all run in the same wifi
j

Jorge R

10/11/2019, 8:51 AM
what would the server do?
because if you want Android as a server, it may be just server UI
and delegate everything to Ktor
you really need an android device to host everything?
would it be possible for you to setup another device with Ktor?
a

Adriano Celentano

10/11/2019, 8:52 AM
I need to have a rest enpoint which calls my Android app
j

Jorge R

10/11/2019, 8:53 AM
so I guess you need android to do something for you
a

Adriano Celentano

10/11/2019, 8:53 AM
Yes that was my first approach to make a ktor Server and communicate with Android via websockets
But i try to find out If i could do the Server directly on android
Without a Middleware
But self signed tls seems to be the Tricky Part to Set up
j

Jorge R

10/11/2019, 8:55 AM
the main problem here is the environment where you will be running your server (Android)
a

Adriano Celentano

10/11/2019, 8:55 AM
Exactly
j

Jorge R

10/11/2019, 8:55 AM
so, i would say fight against the monster (I would not recommend) or try to find a different approach
I’ve been doing projects in Android where I wanted Android as a dedicated device
a

Adriano Celentano

10/11/2019, 8:56 AM
Yeah lets see, If i find sth i can report it here
j

Jorge R

10/11/2019, 8:56 AM
and I can tell you it is not designed for certain tasks
can the task that android have to do being done in other platform (linux, etc)?
v

Viktor Penelski

10/11/2019, 10:14 AM
@Adriano Celentano sorry if I misunderstood, but based on the requirements you mentioned - can't you take advantage of push notifications? That would allow you to send messages from the "outside" to an android device without having to run a dedicated server in your app
a

Adriano Celentano

10/11/2019, 10:50 AM
Yeah was my first solution as well. But i didnt know i also have to communicate back + the api is fixed so i would also need map the incoming request to a push request on firebase or similar
j

Jorge R

10/11/2019, 11:04 AM
also keep in mind that push notif are not 100% guaranteed to arrive
a

Adriano Celentano

10/11/2019, 11:11 AM
We made it work by using a bks certificate :-)
👍 2
21 Views