Skip to content

Commit 3f1013e

Browse files
Merge branch 'master' into signedupdates
2 parents 3de43d6 + 055748f commit 3f1013e

31 files changed

+583
-245
lines changed

doc/esp8266wifi/bearssl-client-secure-class.rst

Lines changed: 214 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
:orphan:
2+
3+
BearSSL Secure Server Class
4+
---------------------------
5+
6+
Implements a TLS encrypted server with optional client certificate validation. See `Server Class <server-class.rst>`__ for general information and `BearSSL Secure Client Class <bearssl-secure-client-class.rst>`__ for basic server and BearSSL concepts.
7+
8+
setBufferSizes(int recv, int xmit)
9+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10+
11+
Similar to the `BearSSL::WiFiClientSecure` method, sets the receive and transmit buffer sizes. Note that servers cannot request a buffer size from the client, so if these are shrunk and the client tries to send a chunk larger than the receive buffer, it will always fail. This must be called before the server is
12+
13+
Setting Server Certificates
14+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
15+
16+
TLS servers require a certificate identifying itself and containing its public key, and a private key they will use to encrypt information with. The application author is responsible for generating this certificate and key, either using a self-signed generator or using a commercial certification authority. **Do not re-use the certificates included in the examples provided.**
17+
18+
This example command will generate a RSA 2048-bit key and certificate:
19+
20+
.. code::
21+
22+
openssl req -x509 -nodes -newkey rsa:2048 -keyout key.pem -out cert.pem -days 4096
23+
24+
Again, it is up to the application author to generate this certificate and key and keep the private key safe and **private.**
25+
26+
setRSACert(const BearSSL::X509List *chain, const BearSSL::PrivateKey *sk)
27+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
28+
29+
Sets a RSA certificate and key to be used by the server when connections are received. Needs to be called before `begin()`
30+
31+
setECCert(const BearSSL::X509List *chain, unsigned cert_issuer_key_type, const BearSSL::PrivateKey *sk)
32+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
33+
34+
Sets an elliptic curve certificate and key for the server. Needs to be called before `begin()`.
35+
36+
Requiring Client Certificates
37+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
38+
39+
TLS servers can request the client to identify itself by transmitting a certificate during handshake. If the client cannot transmit the certificate, the connection will be dropped by the server.
40+
41+
setClientTrustAnchor(const BearSSL::X509List *client_CA_ta)
42+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
43+
44+
Sets the trust anchor (normally a self-signing CA) that all received certificates will be verified against. Needs to be called before `begin()`.

doc/esp8266wifi/client-secure-examples.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ In the next steps we should execute GET command. This is done is similar way as
117117
118118
After sending the request we should wait for a reply and then process received information.
119119

120-
Out of received replay we can skip response header. This can be done by reading until an empty line ``"\r"`` that marks the end of the header:
120+
Out of received reply we can skip response header. This can be done by reading until an empty line ``"\r"`` that marks the end of the header:
121121

122122
.. code:: cpp
123123

doc/esp8266wifi/readme.rst

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,18 +157,32 @@ The Client class creates `clients <https://en.wikipedia.org/wiki/Client_(computi
157157

158158
Check out separate section with `examples <client-examples.rst>`__ / `list of functions <client-class.rst>`__
159159

160-
Client Secure
161-
~~~~~~~~~~~~~
160+
axTLS Client Secure - DEPRECATED
161+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
162162

163-
The Client Secure is an extension of `Client Class <#client>`__ where connection and data exchange with servers is done using a `secure protocol <https://en.wikipedia.org/wiki/Transport_Layer_Security>`__. It supports `TLS 1.1 <https://en.wikipedia.org/wiki/Transport_Layer_Security#TLS_1.1>`__. The `TLS 1.2 <https://en.wikipedia.org/wiki/Transport_Layer_Security#TLS_1.2>`__ is not supported.
163+
The following section details axTLS, the older TLS library used by the project. It is still supported, but additional fixes and documentation will generally not be undertaken. See the following section for the updated TLS client object.
164164

165-
.. figure:: pictures/esp8266-client-secure.png
166-
:alt: ESP8266 operating as the Client Secure
165+
The axTLS Client Secure is an extension of `Client Class <#client>`__ where connection and data exchange with servers is done using a `secure protocol <https://en.wikipedia.org/wiki/Transport_Layer_Security>`__. It supports `TLS 1.1 <https://en.wikipedia.org/wiki/Transport_Layer_Security#TLS_1.1>`__. The `TLS 1.2 <https://en.wikipedia.org/wiki/Transport_Layer_Security#TLS_1.2>`__ is not supported.
167166

168167
Secure applications have additional memory (and processing) overhead due to the need to run cryptography algorithms. The stronger the certificate's key, the more overhead is needed. In practice it is not possible to run more than a single secure client at a time. The problem concerns RAM memory we can not add, the flash memory size is usually not the issue. If you like to learn how `client secure library <https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266WiFi/src/WiFiClientSecure.h>`__ has been developed, access to what servers have been tested, and how memory limitations have been overcame, read fascinating issue report `#43 <https://github.com/esp8266/Arduino/issues/43>`__.
169168

170169
Check out separate section with `examples <client-secure-examples.rst>`__ / `list of functions <client-secure-class.rst>`__
171170

171+
172+
BearSSL Client Secure and Server Secure
173+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
174+
175+
`BearSSL::WiFiClientSecure` and `BearSSL::WiFiServerSecure` are extensions of the standard `Client <#client>`__ and `Server <#server>`__ classes where connection and data exchange with servers and clients using `secure protocol <https://en.wikipedia.org/wiki/Transport_Layer_Security>`__. It supports `TLS 1.2 <https://en.wikipedia.org/wiki/Transport_Layer_Security#TLS_1.2>`__ using a wide variety of modern ciphers, hashes, and key types.
176+
177+
.. figure:: pictures/esp8266-client-secure.png
178+
:alt: ESP8266 operating as the Client Secure
179+
180+
Secure clients and servers require siginificant amounts of additional memory and processing to enable their cryptographic algorithms. In general only a single secure client or server connection at a time can be processed given the little RAM present on the ESP8266, but there are methods of reducing this RAM requirement detailed in the relevant sections.
181+
182+
`BearSSL::WiFiClientSecure <bearssl-client-secure-class.rst>`__ contains more information on using and configuring TLS connections.
183+
184+
`BearSSL::WiFiServerSecure <bearssl-server-secure-class.rst>`__ discusses the TLS server mode available. Please read and understand the `BearSSL::WiFiClientSecure <bearssl-client-secure-class.rst>`__ first as the server uses most of the same concepts.
185+
172186
Server
173187
~~~~~~
174188

doc/esp8266wifi/soft-access-point-class.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ The first parameter of this function is required, remaining four are optional.
5050

5151
Meaning of all parameters is as follows:
5252

53-
- ``ssid`` - character string containing network SSID (max. 63 characters)
54-
- ``password`` - optional character string with a password. For WPA2-PSK network it should be at least 8 character long. If not specified, the access point will be open for anybody to connect.
53+
- ``ssid`` - character string containing network SSID (max. 31 characters)
54+
- ``password`` - optional character string with a password. For WPA2-PSK network it should be at least 8 character long. If not specified, the access point will be open for anybody to connect, (max. 63 characters).
5555
- ``channel`` - optional parameter to set Wi-Fi channel, from 1 to 13. Default channel = 1.
5656
- ``hidden`` - optional parameter, if set to ``true`` will hide SSID.
5757
- ``max_connection`` - optional parameter to set max simultaneous connected stations, `from 0 to 8 <https://bbs.espressif.com/viewtopic.php?f=46&t=481&p=1832&hilit=max_connection#p1832>`__. Defaults to 4. Once the max number has been reached, any other station that wants to connect will be forced to wait until an already connected station disconnects.

doc/libraries.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ Libraries that don't rely on low-level access to AVR registers should work well.
164164
- `DimSwitch <https://github.com/krzychb/DimSwitch>`__ - Control electronic dimmable ballasts for fluorescent light tubes remotely as if using a wall switch.
165165
- `Encoder <https://github.com/PaulStoffregen/Encoder>`__ - Arduino library for rotary encoders. Version 1.4 supports ESP8266.
166166
- `esp8266\_mdns <https://github.com/mrdunk/esp8266_mdns>`__ - mDNS queries and responses on esp8266. Or to describe it another way: An mDNS Client or Bonjour Client library for the esp8266.
167+
- `ESP-NOW <https://github.com/yoursunny/WifiEspNow>`__ - Wrapper lib for ESP-NOW (See `#2227 <https://github.com/esp8266/Arduino/issues/2227>`__)
167168
- `ESPAsyncTCP <https://github.com/me-no-dev/ESPAsyncTCP>`__ - Asynchronous TCP Library for ESP8266 and ESP32/31B
168169
- `ESPAsyncWebServer <https://github.com/me-no-dev/ESPAsyncWebServer>`__ - Asynchronous Web Server Library for ESP8266 and ESP32/31B
169170
- `Homie for ESP8266 <https://github.com/marvinroger/homie-esp8266>`__ - Arduino framework for ESP8266 implementing Homie, an MQTT convention for the IoT.

libraries/DNSServer/src/DNSServer.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
#include <lwip/def.h>
33
#include <Arduino.h>
44

5+
#ifdef DEBUG_ESP_PORT
6+
#define DEBUG_OUTPUT DEBUG_ESP_PORT
7+
#else
8+
#define DEBUG_OUTPUT Serial
9+
#endif
510

611
DNSServer::DNSServer()
712
{
@@ -165,7 +170,7 @@ void DNSServer::replyWithIP(uint8_t* buffer, size_t packetSize)
165170
_udp.endPacket();
166171

167172
#ifdef DEBUG_ESP_DNS
168-
DEBUG_ESP_PORT.printf("DNS responds: %s for %s\n",
173+
DEBUG_OUTPUT.printf("DNS responds: %s for %s\n",
169174
IPAddress(_resolvedIP).toString().c_str(), getDomainNameWithoutWwwPrefix(buffer, packetSize).c_str() );
170175
#endif
171176
}

libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,7 @@ bool HTTPClient::connect(void)
10361036
}
10371037

10381038
#ifdef HTTPCLIENT_1_1_COMPATIBLE
1039-
if(!_client) {
1039+
if(!_client && _transportTraits) {
10401040
_tcpDeprecated = _transportTraits->create();
10411041
_client = _tcpDeprecated.get();
10421042
}

libraries/ESP8266HTTPUpdateServer/examples/SecureBearSSLUpdater/SecureBearSSLUpdater.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ void setup()
101101

102102
MDNS.begin(host);
103103

104-
httpServer.setRSACert(new BearSSLX509List(serverCert), new BearSSLPrivateKey(serverKey));
104+
httpServer.setRSACert(new BearSSL::X509List(serverCert), new BearSSL::PrivateKey(serverKey));
105105
httpUpdater.setup(&httpServer, update_path, update_username, update_password);
106106
httpServer.begin();
107107

libraries/ESP8266WebServer/examples/HelloServerBearSSL/HelloServerBearSSL.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ void setup(void){
123123
Serial.println("MDNS responder started");
124124
}
125125

126-
server.setRSACert(new BearSSLX509List(serverCert), new BearSSLPrivateKey(serverKey));
126+
server.setRSACert(new BearSSL::X509List(serverCert), new BearSSL::PrivateKey(serverKey));
127127

128128
server.on("/", handleRoot);
129129

0 commit comments

Comments
 (0)