Menu

Tree [6b1f27] master /
 History

HTTPS access


File Date Author Commit
 .idea 2023-03-18 User User [923f0e] Commit code for ArduinoLED
 app 2023-03-18 User User [923f0e] Commit code for ArduinoLED
 gradle 2023-03-18 User User [923f0e] Commit code for ArduinoLED
 ssl_server 2023-03-18 User User [923f0e] Commit code for ArduinoLED
 .gitignore 2023-03-18 User User [923f0e] Commit code for ArduinoLED
 README.md 2023-03-18 User User [6b1f27] Test
 build.gradle 2023-03-18 User User [923f0e] Commit code for ArduinoLED
 gradle.properties 2023-03-18 User User [923f0e] Commit code for ArduinoLED
 gradlew 2023-03-18 User User [923f0e] Commit code for ArduinoLED
 gradlew.bat 2023-03-18 User User [923f0e] Commit code for ArduinoLED
 settings.gradle 2023-03-18 User User [923f0e] Commit code for ArduinoLED
 ssl.conf 2023-03-18 User User [923f0e] Commit code for ArduinoLED

Read Me

Arduino LED

This project demonstrates how Arduino (WeMos D1 board) can be used from the smartphone application through HTTPS protocol. In this example we will generate the Certificate Authority and sign certificates. These certificates will be used to secure connection with Arduino.

  • Create the ssl.conf file, which will contain the desired Common Name (CN) and SubjectAlternativeNames. See the example of tnis file in this repository.
  • Generate authority key:
# First generate the certificate authority key.
openssl genrsa -out ca_key.pem 2048
# Generate the CA certificate.
openssl req -x509 -key rsa:4096 -key arduino_ca_key.pem -out arduino_ca_csr.pem -sha256   -days 100500
  • Generate server key and certificate and sign it. Note, we have to set the CN and SubjectAlternativeNames to make sure, we are using the correct domain name.
# Generate server key
openssl genrsa -out server_key.pem 2048
# Create a signing request server_req.csr
openssl req -out server_req.csr -key server_key.pem -new -config ssl.conf
# Sign certificate with authority
openssl x509 -req -in server_req.csr -out server_cer.pem -sha256 -CAcreateserial -CA arduino_ca_csr.pem -CAkey arduino_ca_key.pem -days 100500 -extensions req_ext -extfile ssl.conf
  • [Optional] Create the client key and certificate.
# Key
openssl genrsa -out client1_key.pem 2048
# Signing request
openssl req -out client1_req.csr -key client1_key.pem -new  -config ssl.conf
# Generate certificate
openssl x509 -req -in client1_req.csr -out client1_cer.pem -sha256 -CAcreateserial -days 4000 -CA arduino_ca_csr.pem -CAkey arduino_ca_key.pem  -extensions req_ext -extfile ssl.conf
  • Place arduino_ca_csr.pem, server_key.pem and server_cer.pem to the Secrets folder on the SD card.
  • Create the auth.json file which will contain the authentication information as follows:
{
"ssid": "ssid_of_your_router",
"password": "password to router",
"arduino_ap_ssid": "desired_ssid_of_arduino_ap",
"arduino_ap_password": "password to arduino access point"
}
  • Connect arduino to three color LED (KY-016) and SD card as described in ssl_server.ino in the ssl_server folder and launch the server.
  • Connect to arduino AP and test if you can access server using curl:
# Get the red, green and blue components of the RGB LED in JSON format
curl --cacert /home/User/workspace/IOT/keys/arduino_ca_csr.pem https://ARDUINO.IP.ADDRESS
# Light LED with red color
curl --cacert /home/User/workspace/IOT/keys/arduino_ca_csr.pem https://ARDUINO.IP.ADDRESS --data "red=100" --data "green=0" --data "blue=0"
  • Place arduino CA certificate arduino_ca_csr.pem to app/src/main/res/raw folder and compile the android application.
  • Compile and run the application on Android smartphone.
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.