Skip to content

Working #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 5 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,21 @@
## Working example for ESP32: https://github.com/copercini/esp32-iot-examples/
--------------------------------------------------------------------------------------------


# Some examples using x.509 certificates and TLSv1.2 under Arduino IDE to communicate with AWS iot

After AxTLS update to v2.0.0, the ESP8266 can work with TLS v1.2, the major restriction for this small device communicates with AWS iot natively. You can follow the port here: https://github.com/igrr/axtls-8266

Due heap limitation, the ESP8266 is rebooting before complete handshake, I am hopeful it can be fixed with some optimization.

## How I can get TLS v1.2 working in my ESP8266 with arduino IDE?

#### First: Update libaxtls.a to last version (b20140f)
You can compile it as you own: add xtensa toolchain to your path, and run make. <br />
Or download a compiled one in the folder axtls of this git and replace it on Arduino\hardware\esp8266com\esp8266\tools\sdk\lib of your Arduino git installation (https://github.com/esp8266/Arduino#using-git-version)
## How I can get AWS IoT working in my ESP8266 with arduino IDE?

#### First: Update ESP8266 Arduino core to last git version, [Here are the instructions](https://github.com/esp8266/Arduino#using-git-version)

#### Second: Creating a thing, Downloading and converting AWS iot certificates to DER format
http://docs.aws.amazon.com/iot/latest/developerguide/create-device-certificate.html

Converting PEM to DER format: <br />
$ wget https://www.symantec.com/content/en/us/enterprise/verisign/roots/VeriSign-Class%203-Public-Primary-Certification-Authority-G5.pem > ca.crt <br />
$ openssl x509 -in ca.crt -out certificates/ca.der -outform DER <br />
$ openssl x509 -in aaaaaaaaa-certificate.pem.crt -out certificates/cert.der -outform DER <br />
$ openssl rsa -in aaaaaaaaaa-private.pem.key -out certificates/private.der -outform DER <br />
$ openssl x509 -in aaaaaaaaa-certificate.pem.crt.txt -out cert.der -outform DER <br />
$ openssl rsa -in aaaaaaaaaa-private.pem.key -out private.der -outform DER <br />

copy cert.der and private.der to data folder

#### Third: Uploading a arduino sketch
Some sketch examples are available in examples folder of this git.


## Why it doesn't work yet?
Because AxTLS doens't support the AWS ioT required cipher suites.

State: receiving Server Hello (2) <br />
State: receiving Certificate (11) <br />
State: receiving Certificate Request (13) <br />
State: receiving Server Hello Done (14) <br />
State: sending Certificate (11) <br />
State: sending Client Key Exchange (16)<br />
State: sending Finished (16)<br />
Alert: handshake failure<br />
Error: SSL error 40<br />
<br />
Based on Issue: https://github.com/esp8266/Arduino/issues/2771 <br />
Means: AxTLS library doesn't support needed cipher suites <br />
<br />
4 changes: 3 additions & 1 deletion examples/mqtt_x509_DEM/mqtt_x509_DEM.ino
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ if(espClient.loadPrivateKey(private_key))
else
Serial.println("private key not loaded");


/*
// Load CA file
File ca = SPIFFS.open("/ca.der", "r"); //replace ca eith your uploaded file name
if (!ca) {
Expand All @@ -128,7 +130,7 @@ if(espClient.loadCACert(ca))
Serial.println("ca loaded");
else
Serial.println("ca failed");

*/
Serial.print("Heap: "); Serial.println(ESP.getFreeHeap());

// client.setServer(mqtt_server, 8883);
Expand Down
Loading