0

I'm building a Flutter app that needs to send user data (like name and street) to a Node.js backend server. Currently, the data is sent via URL like this:

http://192.168.1.126:8080/save?name=toto&street=somestreet I want to make this communication secure.

Option 1:

TLS/HTTPS I followed this tutorial: https://www.geeksforgeeks.org/node-js/how-to-use-ssl-tls-with-node-js/ I managed to start a TLS server, but I'm not sure how to connect to it from Flutter.

Question: How can I make an HTTPS request from Flutter to my local Node.js server using a self-signed certificate?

Option 2:

RSA encryption Alternatively, I thought about encrypting the user data (name, street, etc.) with an RSA public key in Flutter, and decrypting it in Node.js using the private key. But I'm stuck on both sides:

I don’t know how to properly encode/encrypt a string in Flutter with a public key.

And I’m not sure how to decrypt it in Node.js.

Any help or working examples for either method would be appreciated!

4
  • 2
    Did you try changing the http:// in the URL to https://? Was there any error when you did that? Commented Aug 4 at 14:03
  • Change http: to https:, change to a POST rather than GET so that the parameters are encrypted. If you are using a self-signed cert follow one of the many tutorials to accept a not-fully-valid server certificate. For example: stackoverflow.com/questions/49839729/… Commented Aug 5 at 22:23
  • Don't use RSA as the maximum payload size will likely be too small. Commented Aug 5 at 22:24
  • It depend on which package do you used to create a http request, if you use Http or Dio the package provide the configuration to insert a certificate. And then you can just make a request, and please make sure to use https: on your link as @FrankvanPuffelen mentioned Commented Aug 22 at 9:03

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.