2

I have a server on my Raspberry Pi with Rasbian on it. To control it, i made a Java TCP/IP client/server. The java Server Side run all the day, and i can connect on it by the Client program. Basically, the Server wait for some code, and execute the command bind to this code. All works perfectly, on my computer and on my Android smartphone. So i add an authentification function. I had a white list and the server check if the client IP (obtained by the socket.getRemoteSocketAddress()) is allowed to connect and send command to my server. I added my computer IP (local IP, because my computer is on the same network than my Raspberry) and i added my smartphone IP too.

My problem is here : Instead of my PC, my smartphone has a dynamic IP. So when i add it's IP to my whitelist, it's works well. But after a few time, my smartphone IP is changed because it's dynamic, so my smartphone isn't allowed anymore.

So i'm searching for a unique key on my smartphone i could use to identify my smartphone and only mine.

Also i need to have a similar key on my computer to identify my computer by the same way.

Do you know a key like that ?

M. Ozn
  • 1,018
  • 1
  • 19
  • 42

1 Answers1

2

I'd use TLS instead of white listing IP's. You can generate a self signed certifcate to use on your server and then manually install the certificate on your phone, computer or any device. Only a device with the certificate will be able to connect to your server.

  • This has the added benefit of also encrypting your connections. – Alexander Hart Apr 05 '16 at 19:54
  • I'm not really familiar with TLS, you mean just a simple .txt file on my smartphone and my computer ? With a manual generated key on it ? – M. Ozn Apr 05 '16 at 19:57
  • A simple manually generated key would work as well. However any connection you expose to the internet should also be encrypted. You may want to look into TLS/SSL. – Alexander Hart Apr 05 '16 at 20:06
  • What do you think about sending the number phone ? So if i have my sim card, i can connect from any smartphone, but only the sim card owner can connect (me) and for my computer i could use a false number ? What do you think about it ? – M. Ozn Apr 05 '16 at 20:20
  • http://stackoverflow.com/questions/2785485/is-there-a-unique-android-device-id/2785493#2785493 – Alexander Hart Apr 05 '16 at 20:53
  • See the above link for a good list of device ID's you could use. – Alexander Hart Apr 05 '16 at 20:54