1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-22 21:23:07 +03:00

71 Commits

Author SHA1 Message Date
Earle F. Philhower, III
9f03bbb8c3
Add an EC keyed certificat to BearSSL Server example (#6202)
Needed for future automated performance test suite use, to allow
selecting between EC and RSA signed keys for the server's cert.
2019-06-14 14:58:29 -07:00
Earle F. Philhower, III
8859b818d8
Make CertStore natively use File interface (#6131)
__This is a breaking change, but the header and example did warn
everyone that this API was in flux due to the incompatible SD and SPIFFS
File implementations.__

BearSSL CertStores now simply need a filesystem and the names of the
data (generated on-chip) and archive (uploaded by user) files on it.
No more need to roll your own virtual CertStoreFile class.

Update the library, examples, and device test.
2019-05-30 12:53:03 -07:00
david gauchard
5dd780c571
udp: restore correct address/port when parsing packet (#6011)
do interleave informations on addresses within reception pbuf chain:
before: (data-pbuf) -> (data-pbuf) -> (data-pbuf) -> ... in the receiving order
now: (address+port-info-pbuf -> data-pbuf) -> (address_port-info-pbuf -> data-pbuf) -> ...

address/port informations are updated along with data exposed to user
2019-04-26 20:09:23 +02:00
Earle F. Philhower, III
f6dd826437
Fix MFLN probe and allow returning whether MFLN succeeded or not after a connection. (#6000)
Fixes #5996

* Add extensions to probe message for EC, others

probeMFLN was failing on some connection attempts to servers which only
supported EC based ciphers because it did not include the proper TLS
handshake extensions to list what kinds of ECs it supported.

Add those to the probeMFLN ClientHello message to make probes pass.

* Add client.getMFLNStatus method, returns MFLN state

After a connection it is useful to check whether MFLN negotiation
succeeded.  getMFLNStatus returns a bool (valid only after
client.connect() succeeds, of course) indicating whether the requested
buffer sizes were negotiated successfully.
2019-04-25 12:40:26 -07:00
Jeroen88
667816ebe0 BearSSL Max Fragment Length Negotation and Node.js server (#5929)
* Minor bug fixes in Maximum Fragment Length Negotation example, mainly giving background processes some time in fetch()

* Minor layout changes to pass travis tests

* Use PolledTimeout for timeout
2019-04-11 14:21:04 +02:00
david gauchard
9a2ed274f3 polledTimeout: add option to use CPU count instead of millis() (#5870)
* polledTimeout: add option to use CPU count instead of millis()

* use more "using" alias

* more c++/clear code, using typename (thanks @devyte)

* rename class name to include unit, introduce timeMax() and check it with assert()

* remove useless defines

* improve api readability, add micro-second unit

* update example

* mock: emulate getCycleCount, add/fix polledTimeout CI test

* + nano-seconds, assert -> message, comments, host test

* allow 0 for timeout (enables immediate timeout, fix division by 0)

* typo, set member instead of local variable

* unify error message

* slight change on checkExpired() allows "never expired"
also removed printed message, add YieldAndDelay, simplify calculations

* remove traces of debug.h/cpp in this PR

* include missing <limits> header

* back to original expired test, introduce boolean _neverExpires, fix reset(), getTimeout() is invalid

* fix expiredOneShot with _timeout==0 check

* reenable getTimeout()

* expose checkExpired with unit conversion

* fix timing comments, move critical code to iram

* add member ::neverExpires and use it where relevant

* improve clarity

* remove exposed checkExpired(), adapt LEAmDNS with equivalent

* add API ::resetToNeverExpires(), use it in LEAmDNS

* remove offending constness from ::flagged() LEAmDNS (due do API fix in PolledTimeout)

* simplify "Fast" base classes

* minor variable rename

* Fix examples

* compliance with good c++ manners

* minor changes for consistency

* add missing const

* expired() and bool() moved to iram

* constexpr compensation computing

* add/update comments

* move neverExpires and alwaysExpired
2019-04-05 10:50:53 -03:00
Jiri Bilek
64e30b270b Fix the changed structure of the input file (#5891)
The input file containing certificates has changed.
2019-03-18 15:15:59 -07:00
david gauchard
f42bfdfc0d
adaptations for lwIP-v1.4 (#5682)
* adaptations for lwIP-v1.4
* add lwIP-v1.4 in CI
2019-01-28 22:31:59 +01:00
SmartBlug
5e4c2e9750 Add capability to have light static DHCP lease (#5594)
* Add capability to have light static DHCP lease

* added ESP8266WiFi StaticLease sample

* Update StaticLease to IPv4
2019-01-25 02:25:04 +00:00
david gauchard
cac22e3576
fix dhcp6 in upstream lwIP (#5560) 2018-12-27 19:29:04 +01:00
david gauchard
da7ffdaa28
add 1 more IPAddress constructor for IPv6 (#5551) 2018-12-26 15:01:48 +01:00
david gauchard
f8f4b81d60 better compatibility for IPAddress changes with external libraries (#5438) 2018-12-04 23:32:24 -03:00
david gauchard
216680bb57 weak hook preinit() #2111 #2133 #2136 (#5395)
* weak hook early_setup() #2111 #2133 #2136

* rename to early_init (more "c" vs early_setup which is more "c++arduino")

* example

* improve earlyWiFi example, slightly change AddrList interface, move WiFi sketches into WiFi examples

* fix CI

* fix local CI runner

* fix local CI runner

* rename early_init() to preinit()

* + static ESP8266WiFiClass::preinit_wifi_off()

* update early disable wifi example

* example update

* IPv6 example update

* Update ESP8266WiFiGeneric.h

camelCase for static method name

* Update ESP8266WiFiGeneric.cpp

camelCase for static method name

* Update EarlyDisableWiFi.ino

Expand comment, fix static method name

* Update core_esp8266_main.cpp

Expanded comment.

* Update core_esp8266_main.cpp

Expanded comment

* Update EarlyDisableWiFi.ino

Expanded comment
2018-12-03 20:54:27 -08:00
david gauchard
50cbdc0b92 update AddrList and examples (#5422) 2018-12-03 15:15:50 -03:00
david gauchard
92373a9837 Deprecate axTLS, update examples (#5366)
* update examples

* fix serial<->tcp example, use STASSID instead of SSID (name collision)

* fix HTTPSRequest.ino

* update AxTLS HTTPS examples, update AxTLS API to deprecated

* fixes

* fixes + fix astyle (no preproc directives) + restyling script

* fix HTTPClient library

* fixes

* common.sh: do not reload arduino when already present (for locally CI testing)

* common.sh: do not reload ArduinoJson when already present (for locally CI testing)

* fix

* fix

* fix deprecated example

* fix WiFiHTTPSServer.ino

* reduce footprint

* wipfix

* fix led builtin

* fix example

* finished updating APSSID on all examples

* style

* restyle examples

* helper to run CI test locally

* local CI runner more verbose

* +const

* deprecation deprecation

* deprecation

* Update NTPClient.ino

const char[] => const char *

* Update interactive.ino

const char[] => const char *
2018-11-29 20:49:27 -08:00
david gauchard
74ca42f829 Sketch emulation on host (#5342)
* WIP compile examples on host with 'make examples'

* WIP bufferize tcp input

* WIP Makefile

* WIP network to rework, tcp/udp to factorize, udp addresses broken

* minor changes to the core

* WIP basic udp working

* WIP mdns

* WIP mcast receiving, not sending

* WIP mdns OK

* beta version

* SSL + doc

* update travis host test command

* licenses

* typo

* doc: arduino builder is not around: declare functions before calling them

* fix with latest SSL PR, compile in 32 bits mode

* fix make clean

* make -m32 optional

* 32bits compiler ability tester

* WIP

* WIP (fix 1 vtable error, still another one to hunt with using spiffs)

* example astyle

* fix os_printf_plus

* load / save mock spiffs

* fix style

* fix using spiffs/mock

* don't mess ram

* update doc

* remove leftover

* optimization -Os except for CI, rename ARCH32 to FORCE32

* revert useless cast (not even compiled)

* remove unused function

* use proper type for pointer arithmetics

* makefile: sketch object and cpp file moved to bin/ directories
easier to clean, and IDE don't like them

* changes for review

* make use of %zd

* less verbose makefile by default (option)

* update readme
2018-11-20 18:51:45 -02:00
Earle F. Philhower, III
233d3e3b5e
Move BearSSLHelpers into BearSSL namespace (#5315)
BearSSLX509List, BearSSLSession, BearSSLPublicKey, and BearSSLPrivateKey
were all in the global namespace and not in the BearSSL:: one, due to an
oversight when they were originally created.  Move them to the proper
namespace with the following mapping:
    BearSSLX509List => BearSSL::X509List
    BearSSLSession => BearSSL::Session
    BearSSLPublicKey => BearSSL::PublicKey
    BearSSLPrivateKey => BearSSL::PrivateKey
2018-11-06 19:27:40 -08:00
dsv19
ef95e05319 examples code cleanup (#5290)
* Update WiFiMulti.ino

* Update WiFiClientBasic.ino

* Update WiFiWebServer.ino

* Update WiFiClient.ino

* Update WiFiHTTPSServer.ino
2018-10-28 23:29:03 -03:00
Earle F. Philhower, III
1b1b0a28a8
Add stack repainting call to ESP class (#5221)
Allow the unused stack to be reset to the check value at any time in
the application, allowing for delta-stack calculations to be done.

Add ESP.resetFreeContStack() class method for general use.

Add in some dumping in the BearSSL_Validation example to show the
usage for those that care.
2018-10-11 08:55:30 -07:00
Junxiao Shi
d17ffc2874 WiFi: improve WiFiClient(Basic) examples (#5197)
WiFiClient no longer depends on now-defunct data.sparkfun.com
service, but uses a TCP "quote of the day" service instead.

fixes #4088
2018-10-11 02:08:13 -03:00
Earle F. Philhower, III
18612c97d8
Add BearSSL::setFingerprint(char* fp) (#5204)
Add a method allowing a user to send in a character string for the
fingerprint, like axTLS supported.

Implements part of PR #4833 from @d-a-v with changes requested in
discussion.
2018-10-03 19:32:47 -07:00
Earle F. Philhower, III
6314093fe5
Add SSL Session capability to speed reconnections (#5160)
SSL Sessions enable most of the SSL handshake to be skipped when both
client and server agree to use them.  Add a BearSSLSession class and
an optional setting to the SSL client to enable this.

Note that SSL sessions are unrelated to HTTP sessions.  They are
ephemeral and only relate to the SSL parameters, not anything at
the HTTP protocol level.
2018-09-28 12:03:20 -07:00
Earle F. Philhower, III
cc284bb533 Allow cipher specification for BearSSL (#5151)
* Allow cipher specification for BearSSL

BearSSL has many more ciphers than axTLS, but they are more compute intensive
and slower.  Add an option to use only the same, limited security, axTLS ciphers
as well as allow users to specify any suite of ciphers they want using standard
BearSSL formats.

Fixes #5110

* Rename methods to avoid axtls references.

* Allow std::vector to set a list of allowed ciphers

For C++ afficionados, allow std::vectors to be passed in to the setCipher()
routine.

The BearSSL object will now keep a copy of any set ciphers and free on object
destruction.  These custom lists should normally only be 1-4 entries long, so it
is not expected to be a memory hog having this extra copy.
2018-09-21 11:47:20 -03:00
Earle F. Philhower, III
1a44f79a9e
Update api.github.com certificate signature (#5145)
Fixes #5144
2018-09-18 08:28:16 -07:00
Earle F. Philhower, III
cd43337f4f Fix connection options and update github pubkey (#5120)
As part of the "clear connection configuration for reused objects"
patch, a ::stop would reset the self-signed, trust anchors, etc.
WiFiClient, unfortunately, calls ::stop as part of the connection
process, so all of these settings were lost.

Now only clear the connection settings on ::stop if we've already
been connected.

Also update the github public key which changed yet again.

Fixes #5086
2018-09-16 23:24:42 -03:00
Develo
4fdff072e8
read all lines from slow servers (#5113)
Replaces #1829
2018-09-07 15:07:59 -03:00
Earle F. Philhower, III
56b98fd4df Move all PROGMEM to their own section (#5048)
According to the GCC man page, __section__ attributes should only be used
for global variables.  However, the PROGMEM and ICACHE_RODATA macros use
this variable decorator even for local variables.  Most of the time it works,
but when a static or inlined function tries to use a PROGMEM/PSTR/etc.
variable the compiler can throw an error like:
  error: XXX causes a section type conflict with YYY

Change the PROGMEM macro to emit a section name that is unique (a combo
of the file, line, and counter variables to ensure uniqueness).  The
standard linker script will place them properly in .IROM without
any changes.

Fixes #5036 and others.
2018-08-15 11:46:13 -03:00
Earle F. Philhower, III
53091882b8
Fix minor BearSSL API issues (#4901)
Fixes #4882 and updates GitHub certificate fingerprint to the current one
in BearSSL_Validation example.

When setting a authentication mode or stopping, clear all others out in case
the object is being re-used.

Add in a yield during the SSL handshake to allow a graceful timeout and not
a WDT error when the remote server hiccups.  Thanks to @Jeroen88 for
finding and testing this.
2018-07-16 09:35:00 -07:00
Earle F. Philhower, III
89d2f42153
Note that CERTS.IDX file is generated on-chip (#4902)
Several users have been worried that they need to generate the IDX file,
but don't know how.  The CertStore code actually writes this file on object
creation, and the user never needs to explicitly generate or upload it.

Add a comment to the example explicitly noting this.
2018-07-08 21:54:40 -07:00
Earle F. Philhower, III
945535ae78
Make ar compatible with GNU and BSD in example (#4907)
Change the "ar" options in the example CertStore.AR archive generator to
make them compatible with both Linux and MacOS.
2018-07-08 21:12:32 -07:00
Earle F. Philhower, III
794630e068
Remove dependency on SD/SPIFFS from CertStore (#4760)
Due to popular demand, remove the hardcoded dependency on SPIFFS
or SD from the CertStore by factoring out the file interface into
a new class (CertStoreFile) that the user will need to implement
as a thin wrapper around either a SPIFFS.file or a SD.file

Combine the downloaded certificates into a UNIX "ar" archive
and parse that on-the-fly to allow easy inspection and creation
of the Cert Store database.

Examples updated with a new certificate downloader that creates
the certs.ar archive and with a single sample that can be built
for either SPIFFS or SD with a #define.  Users can copy the
implementation of the CertStoreFile they need to their own code
as it is self-contained.

Also move the CertStore to the BearSSL namespace and remove the
suffix and separate SPIFFS/SD sources.

Remove the "deep+" change from the CI build as well (no special
options needed on any PIO or makefile build).

We'll revisit the filesystem wrapper for 2.5.0, hopefully having a
unified template for both filesystem usage at a global level.  For
current users, be aware the interface may change (simplify!) in
release 2.5.0.

Fixes #4740
2018-06-12 19:06:26 -07:00
Earle F. Philhower, III
e3c970210f
Add BearSSL client and server, support true bidir, lower memory, modern SSL (#4273)
BearSSL (https://www.bearssl.org) is a TLS(SSL) library written by
Thomas Pornin that is optimized for lower-memory embedded systems
like the ESP8266. It supports a wide variety of modern ciphers and
is unique in that it doesn't perform any memory allocations during
operation (which is the unfortunate bane of the current axTLS).

BearSSL is also absolutely focused on security and by default performs
all its security checks on x.509 certificates during the connection
phase (but if you want to be insecure and dangerous, that's possible
too).

While it does support unidirectional SSL buffers, like axTLS,
as implemented the ESP8266 wrappers only support bidirectional
buffers. These bidirectional buffers avoid deadlocks in protocols
which don't have well separated receive and transmit periods.

This patch adds several classes which allow connecting to TLS servers
using this library in almost the same way as axTLS:
BearSSL::WiFiClientSecure - WiFiClient that supports TLS
BearSSL::WiFiServerSecure - WiFiServer supporting TLS and client certs

It also introduces objects for PEM/DER encoded keys and certificates:
BearSSLX509List - x.509 Certificate (list) for general use
BearSSLPrivateKey - RSA or EC private key
BearSSLPublicKey - RSA or EC public key (i.e. from a public website)

Finally, it adds a Certificate Authority store object which lets
BearSSL access a set of trusted CA certificates on SPIFFS to allow it
to verify the identity of any remote site on the Internet, without
requiring RAM except for the single matching certificate.
CertStoreSPIFFSBearSSL - Certificate store utility

Client certificates are supported for the BearSSL::WiFiClientSecure, and
what's more the BearSSL::WiFiServerSecure can also *require* remote clients
to have a trusted certificate signed by a specific CA (or yourself with
self-signing CAs).

Maximum Fragment Length Negotiation probing and usage are supported, but
be aware that most sites on the Internet don't support it yet.  When
available, you can reduce the memory footprint of the SSL client or server
dramatically (i.e. down to 2-8KB vs. the ~22KB required for a full 16K
receive fragment and 512b send fragment).  You can also manually set a
smaller fragment size and guarantee at your protocol level all data will
fit within it.

Examples are included to show the usage of these new features.

axTLS has been moved to its own namespace, "axtls".  A default "using"
clause allows existing apps to run using axTLS without any changes.

The BearSSL::WiFi{client,server}Secure implements the axTLS
client/server API which lets many end user applications take advantage
of BearSSL with few or no changes.

The BearSSL static library used presently is stored at
https://github.com/earlephilhower/bearssl-esp8266 and can be built
using the standard ESP8266 toolchain.
2018-05-14 20:46:47 -07:00
Ivan Grokhotkov
61cd8d8385 examples: format all .ino files
This formats all the example source files using Arduino style rules.
2018-03-08 14:32:06 +08:00
Earle F. Philhower, III
f9ac524b13
Add -Werror to acceptance builds for C and CPP (#4369)
Use platform.local.txt to add -Werror to GCC for the build of all
code.  Any warnings on a submitted patch will cause an error.

Several examples and libraries had warnings/errors (missing returns
on functions, types, etc.).  Clean those up with this commit as well.
2018-02-17 18:47:10 -08:00
Earle F. Philhower, III
c8dbfb160b Refrech api.github.com x509 certificate (#4306)
The certificate fingerprint included with the HTTPSRequest example seems
to be for an expired api.github.com certificate.  Replace with the current
one to avoid reporting "certificate mismatch" errors when running.
2018-02-06 11:06:05 -03:00
NameOfTheRose
84228b1c73 Nameoftherose patch for Issue #2435 (#4256)
* WiFiTelnetToSerial Example - Minor Issues #2435

* WiFiTelnetToSerial Example - Minor Issues #2435

Patch to rectify issue #2435
2018-01-29 13:28:28 -03:00
Earle F. Philhower, III
bd1c7ce1dc Add SSL enabled WiFiServer, Updater, WebServer
Adds SSL server mode for WiFiServerSecure, for plain SSL connections,
ESP8266WebServerSecure, for HTTPS web serving, and SecureHTTPSUpdater for
encrypted OTA updates.

Example code is provided for all new options, as well as a BASH script for
generating their own, self-signed certificates.

Both ESP8266WebServerSecure and SecureHTTPSUpdater are important for secure
password-based authentication.  HTTP Basic Authentication, the only supported
model presently, sends the username and password in *cleartext* and therefore
should *never* be used in any un-SSL encrypted channel unless you don't mind
sharing your login and password with anyone else on the internet.  Even if the
ESP8266 is not safety critical, this cleartext broadcast could expose you should
you reuse this password elsewhere on your network or the internet.
2018-01-10 11:56:32 +08:00
Hans Winzell
7dd50360b9 Fix bug in WiFiClientBasic.ino (#3902) 2017-12-28 09:47:10 -03:00
david gauchard
d5bb4a99f6 in example properly wait for NTP to be set (#4000)
fix #3905
2017-12-21 16:27:58 -03:00
Develo
7df2858285
Fix comment misnomer (#3939) 2017-12-08 15:58:46 -03:00
Rotzbua
31abb6e5e1 [doc] update HTTPSRequest.ino (#3925)
add limitations of https connections
2017-12-08 03:38:19 -03:00
James Stanley
2abbc36da4 Put WiFi into station mode in examples (#3731) 2017-10-22 13:53:01 +08:00
Ivan Grokhotkov
84b046f98c WiFiClientSecure: add support for keys and certificates in PROGMEM 2017-10-08 05:04:04 +08:00
Ivan Grokhotkov
a8e8ecb687 WiFiClientSecure: add example of setCACert/verifyCertChain
Ref #1851
2017-05-21 22:00:33 -05:00
Ivan Grokhotkov
808bf50ff2 wifi: add SoftAPModeProbeRequestReceived event handler (#2917)
- add probe request event handler (#2910)
- update WiFi events handling example to use new handler

Pro tip: replace blinking LED with ‘analogWrite’ and connect the pin to
a loudspeaker (or use a servo to hit a bell). Get notified when someone
with a smartphone wanders around your country house.
2017-02-06 13:24:34 +03:00
WereCatf
d46d742db1 Use WIFI_STA in WiFiClient-examples
Many people have problems with using ESP8266 as WiFi-client due to
none of the examples mentioning that you should use WIFI_STA if you
only want the ESP8266 to act as a WiFi-client. Many WiFi-devices
will randomly try to connect to the ESP8266 if used as STA+AP and
complain about not being able to access the Internet or other devices
on the network.
2016-10-29 12:40:06 +03:00
Hemal Chevli
e4e182a966 Rectified mistake in if condition
thanks to @chaeplin for finding the mistake
2016-04-05 13:12:22 +05:30
Hemal Chevli
81859c5df6 Changed timeout logic
Changed timeout to unsigned long. Using addition with millis() is not recommended. 
Source: http://www.gammon.com.au/millis
2016-04-05 10:53:15 +05:30
Markus Sattler
0ed104f028 add WiFi Event example 2015-12-29 14:38:13 +01:00
Martin Ayotte
e166e85f73 oupps ! I forgot to set the timout value 2015-12-06 09:47:00 -05:00