1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00
esp8266/doc/esp8266wifi/client-secure-class.rst
Earle F. Philhower, III 83166f948b
Deprecate SPIFFS, move examples to LittleFS (#7263)
* Deprecate SPIFFS, move examples to LittleFS

SPIFFS has been a great filesystem, but it has significant problems in
many cases (and it's also pretty slow).  Development seems to have
slowed/stopped on the upstream version, and we're not able to provide
support or fix the known issues with it as-is.

Deprecate SPIFFS variable.

Update all examples to use LittleFS instead of SPIFFS.

Also, minor cleanup on very old examples which has obsolete delays
waiting for the Serial port to come up, or which were stuck at 9600 baud
because of their ancient AVR heritage.

Fixes #7095

* Remove leftover debug code

* Clean up comments in some examples

* Update documentation on SPIFFS deprecation

* Fix host tests to avoid deprecation warnings

* Fix cut-n-paste error

* Restore SpeedTest.ino, adjust to allow custom FSes

Co-authored-by: Develo <deveyes@gmail.com>
2020-05-04 14:22:50 -04:00

2.6 KiB

orphan

Client Secure Class

Methods and properties described in this section are specific to ESP8266. They are not covered in Arduino WiFi library documentation. Before they are fully documented please refer to information below.

Supported crypto

In the background the library axtls is used. The library supports only rsa certificates and no new eliptic curve certificates. TLSv1.2 is supported since SDK 2.4.0-rc1.

The following ciphers and digests are supported by specification:

  • Symmetric Ciphers
    • AES128-SHA
    • AES256-SHA
    • AES128-SHA256
    • AES256-SHA256
  • Asymmetric Ciphers
    • RSA 512/1024/2048/4096 bit encryption/decryption.
    • RSA signing/verification
  • Digests
    • SHA1
    • MD5
    • SHA256/384/512
    • HMAC-SHA1
    • HMAC-MD5
    • HMAC-SHA256

loadCertificate

Load client certificate from file system.

loadCertificate(file) 

Declarations

#include <FS.h>
#include <LittleFS.h>
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>

const char* certificateFile = "/client.cer";

setup() or loop()

if (!LittleFS.begin())
{
  Serial.println("Failed to mount the file system");
  return;
}

Serial.printf("Opening %s", certificateFile);
File crtFile = LittleFS.open(certificateFile, "r");
if (!crtFile)
{
  Serial.println(" Failed!");
}

WiFiClientSecure client;

Serial.print("Loading %s", certificateFile);
if (!client.loadCertificate(crtFile))
{
  Serial.println(" Failed!");
}

// proceed with connecting of client to the host

setCertificate

Load client certificate from C array.

setCertificate (array, size) 

For a practical example please check this interesting blog.

Other Function Calls

bool  verify (const char *fingerprint, const char *domain_name) 
void  setPrivateKey (const uint8_t *pk, size_t size) 
bool  loadCertificate (Stream &stream, size_t size) 
bool  loadPrivateKey (Stream &stream, size_t size) 
template<typename TFile >  bool  loadPrivateKey (TFile &file)

Documentation for the above functions is not yet prepared.

For code samples please refer to separate section with examples dedicated specifically to the Client Secure Class.