Skip to content

Commit 85ba53a

Browse files
Remove stray axtls refs, deprecated compat funcs (#7626)
Remove the axTLS compatability functions from WiFiClient/ServerSecure, device tests for axTLS, and any document refs to axTLS.
1 parent 7c8f934 commit 85ba53a

File tree

6 files changed

+4
-218
lines changed

6 files changed

+4
-218
lines changed

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,14 @@ BearSSL::WiFiClientSecure Class
120120
Validating X509 Certificates (Am I talking to the server I think I'm talking to?)
121121
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
122122

123-
Prior to connecting to a server, the `BearSSL::WiFiClientSecure` needs to be told how to verify the identity of the other machine. **By default BearSSL will not validate any connections and will refuse to connect to any server.** This is a significant difference from the earlier `axTLS::WiFiClientSecure` in that the deprecated axTLS client would connect to any server and would only attempt to validate the identity of the remote server if asked to, after connection.
123+
Prior to connecting to a server, the `BearSSL::WiFiClientSecure` needs to be told how to verify the identity of the other machine. **By default BearSSL will not validate any connections and will refuse to connect to any server.**
124124

125125
There are multiple modes to tell BearSSL how to verify the identity of the remote server. See the `BearSSL_Validation` example for real uses of the following methods:
126126

127127
setInsecure()
128128
^^^^^^^^^^^^^
129129

130-
Don't verify any X509 certificates. There is no guarantee that the server connected to is the one you think it is in this case, but this call will mimic the behavior of the deprecated axTLS code.
130+
Don't verify any X509 certificates. There is no guarantee that the server connected to is the one you think it is in this case.
131131

132132
setKnownKey(const BearSSL::PublicKey \*pk)
133133
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -198,7 +198,7 @@ If you are connecting to a server repeatedly in a fixed time period (usually 30
198198
Errors
199199
~~~~~~
200200

201-
BearSSL can fail in many more unique and interesting ways then the deprecated axTLS. Use these calls to get more information when something fails.
201+
BearSSL can fail in many more unique and interesting ways. Use these calls to get more information when something fails.
202202

203203
getLastSSLError(char \*dest = NULL, size_t len = 0)
204204
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -218,4 +218,4 @@ Takes an array (in PROGMEM is valid) or a std::vector of 16-bit BearSSL cipher i
218218
setCiphersLessSecure()
219219
^^^^^^^^^^^^^^^^^^^^^^
220220

221-
Helper function which essentially limits BearSSL to ciphers that were supported by the deprecated axTLS. These may be less secure than the ones BearSSL would natively choose, but they may be helpful and faster if your server depended on specific axTLS crypto options.
221+
Helper function which essentially limits BearSSL to less secure ciphers than it would natively choose, but they may be helpful and faster if your server depended on specific crypto options.

libraries/ESP8266WiFi/src/WiFiClientSecureBearSSL.cpp

-82
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ void WiFiClientSecure::_clearAuthenticationSettings() {
9797
_use_self_signed = false;
9898
_knownkey = nullptr;
9999
_ta = nullptr;
100-
_axtls_ta = nullptr;
101100
}
102101

103102

@@ -106,8 +105,6 @@ WiFiClientSecure::WiFiClientSecure() : WiFiClient() {
106105
_clearAuthenticationSettings();
107106
_certStore = nullptr; // Don't want to remove cert store on a clear, should be long lived
108107
_sk = nullptr;
109-
_axtls_chain = nullptr;
110-
_axtls_sk = nullptr;
111108
stack_thunk_add_ref();
112109
}
113110

@@ -124,10 +121,6 @@ WiFiClientSecure::~WiFiClientSecure() {
124121
_cipher_list = nullptr; // std::shared will free if last reference
125122
_freeSSL();
126123
stack_thunk_del_ref();
127-
// Clean up any dangling axtls compat structures, if needed
128-
_axtls_ta = nullptr;
129-
_axtls_chain = nullptr;
130-
_axtls_sk = nullptr;
131124
}
132125

133126
WiFiClientSecure::WiFiClientSecure(ClientContext* client,
@@ -1576,79 +1569,4 @@ bool WiFiClientSecure::probeMaxFragmentLength(IPAddress ip, uint16_t port, uint1
15761569
return _SendAbort(probe, supportsLen);
15771570
}
15781571

1579-
1580-
// AXTLS compatibility interfaces
1581-
bool WiFiClientSecure::setCACert(const uint8_t* pk, size_t size) {
1582-
_axtls_ta = nullptr;
1583-
_axtls_ta = std::shared_ptr<X509List>(new X509List(pk, size));
1584-
_ta = _axtls_ta.get();
1585-
return _ta ? true : false;
1586-
}
1587-
1588-
bool WiFiClientSecure::setCertificate(const uint8_t* pk, size_t size) {
1589-
_axtls_chain = nullptr;
1590-
_axtls_chain = std::shared_ptr<X509List>(new X509List(pk, size));
1591-
_chain = _axtls_chain.get();
1592-
return _chain ? true : false;
1593-
}
1594-
1595-
bool WiFiClientSecure::setPrivateKey(const uint8_t* pk, size_t size) {
1596-
_axtls_sk = nullptr;
1597-
_axtls_sk = std::shared_ptr<PrivateKey>(new PrivateKey(pk, size));
1598-
_sk = _axtls_sk.get();
1599-
return _sk ? true : false;
1600-
1601-
}
1602-
1603-
uint8_t *WiFiClientSecure::_streamLoad(Stream& stream, size_t size) {
1604-
uint8_t *dest = (uint8_t*)malloc(size);
1605-
if (!dest) {
1606-
return nullptr;
1607-
}
1608-
if (size != stream.readBytes(dest, size)) {
1609-
free(dest);
1610-
return nullptr;
1611-
}
1612-
return dest;
1613-
}
1614-
1615-
bool WiFiClientSecure::loadCACert(Stream& stream, size_t size) {
1616-
uint8_t *dest = _streamLoad(stream, size);
1617-
bool ret = false;
1618-
if (dest) {
1619-
#pragma GCC diagnostic push
1620-
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
1621-
ret = setCACert(dest, size);
1622-
#pragma GCC diagnostic pop
1623-
}
1624-
free(dest);
1625-
return ret;
1626-
}
1627-
1628-
bool WiFiClientSecure::loadCertificate(Stream& stream, size_t size) {
1629-
uint8_t *dest = _streamLoad(stream, size);
1630-
bool ret = false;
1631-
if (dest) {
1632-
#pragma GCC diagnostic push
1633-
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
1634-
ret = setCertificate(dest, size);
1635-
#pragma GCC diagnostic pop
1636-
}
1637-
free(dest);
1638-
return ret;
1639-
}
1640-
1641-
bool WiFiClientSecure::loadPrivateKey(Stream& stream, size_t size) {
1642-
uint8_t *dest = _streamLoad(stream, size);
1643-
bool ret = false;
1644-
if (dest) {
1645-
#pragma GCC diagnostic push
1646-
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
1647-
ret = setPrivateKey(dest, size);
1648-
#pragma GCC diagnostic pop
1649-
}
1650-
free(dest);
1651-
return ret;
1652-
}
1653-
16541572
};

libraries/ESP8266WiFi/src/WiFiClientSecureBearSSL.h

-70
Original file line numberDiff line numberDiff line change
@@ -131,68 +131,6 @@ class WiFiClientSecure : public WiFiClient {
131131
static bool probeMaxFragmentLength(const char *hostname, uint16_t port, uint16_t len);
132132
static bool probeMaxFragmentLength(const String& host, uint16_t port, uint16_t len);
133133

134-
////////////////////////////////////////////////////
135-
// AxTLS API deprecated warnings to help upgrading
136-
137-
#define AXTLS_DEPRECATED \
138-
__attribute__((deprecated( \
139-
"This is deprecated AxTLS API, " \
140-
"check https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266WiFi/src/WiFiClientSecure.h#L25-L99")))
141-
142-
bool setCACert(const uint8_t* pk, size_t size) AXTLS_DEPRECATED;
143-
bool setCertificate(const uint8_t* pk, size_t size) AXTLS_DEPRECATED;
144-
bool setPrivateKey(const uint8_t* pk, size_t size) AXTLS_DEPRECATED;
145-
146-
bool loadCACert(Stream& stream, size_t size) AXTLS_DEPRECATED;
147-
bool loadCertificate(Stream& stream, size_t size) AXTLS_DEPRECATED;
148-
bool loadPrivateKey(Stream& stream, size_t size) AXTLS_DEPRECATED;
149-
150-
#pragma GCC diagnostic push
151-
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
152-
153-
bool setCACert_P(PGM_VOID_P pk, size_t size) AXTLS_DEPRECATED {
154-
return setCACert((const uint8_t *)pk, size);
155-
}
156-
157-
bool setCertificate_P(PGM_VOID_P pk, size_t size) AXTLS_DEPRECATED {
158-
return setCertificate((const uint8_t *)pk, size);
159-
}
160-
161-
bool setPrivateKey_P(PGM_VOID_P pk, size_t size) AXTLS_DEPRECATED {
162-
return setPrivateKey((const uint8_t *)pk, size);
163-
}
164-
165-
#pragma GCC diagnostic pop
166-
167-
template<typename TFile>
168-
bool loadCertificate(TFile& file) {
169-
return loadCertificate(file, file.size());
170-
}
171-
172-
template<typename TFile>
173-
bool loadPrivateKey(TFile& file) {
174-
return loadPrivateKey(file, file.size());
175-
}
176-
177-
template<typename TFile>
178-
bool loadCACert(TFile& file) {
179-
return loadCACert(file, file.size());
180-
}
181-
182-
bool verify(const char* fingerprint, const char* domain_name) AXTLS_DEPRECATED {
183-
(void)fingerprint;
184-
(void)domain_name;
185-
return connected();
186-
}
187-
188-
bool verifyCertChain(const char* domain_name) AXTLS_DEPRECATED {
189-
(void)domain_name;
190-
return connected();
191-
}
192-
193-
// AxTLS API deprecated section end
194-
/////////////////////////////////////
195-
196134
protected:
197135
bool _connectSSL(const char *hostName); // Do initial SSL handshake
198136

@@ -219,14 +157,6 @@ class WiFiClientSecure : public WiFiClient {
219157
bool _handshake_done;
220158
bool _oom_err;
221159

222-
// AXTLS compatibility shim elements:
223-
// AXTLS managed memory for certs and keys, while BearSSL assumes
224-
// the app manages these. Use this local storage for holding the
225-
// BearSSL created objects in a shared form.
226-
std::shared_ptr<X509List> _axtls_ta;
227-
std::shared_ptr<X509List> _axtls_chain;
228-
std::shared_ptr<PrivateKey> _axtls_sk;
229-
230160
// Optional storage space pointer for session parameters
231161
// Will be used on connect and updated on close
232162
Session *_session;

libraries/ESP8266WiFi/src/WiFiServerSecureBearSSL.cpp

-16
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ WiFiServerSecure::WiFiServerSecure(const WiFiServerSecure &rhs) : WiFiServer(rhs
5656

5757
WiFiServerSecure::~WiFiServerSecure() {
5858
stack_thunk_del_ref();
59-
_axtls_chain = nullptr;
60-
_axtls_sk = nullptr;
6159
}
6260

6361
// Specify a RSA-signed certificate and key for the server. Only copies the pointer, the
@@ -103,18 +101,4 @@ WiFiClientSecure WiFiServerSecure::available(uint8_t* status) {
103101
return WiFiClientSecure();
104102
}
105103

106-
107-
void WiFiServerSecure::setServerKeyAndCert(const uint8_t *key, int keyLen, const uint8_t *cert, int certLen) {
108-
_axtls_chain = nullptr;
109-
_axtls_sk = nullptr;
110-
_axtls_chain = std::shared_ptr<X509List>(new X509List(cert, certLen));
111-
_axtls_sk = std::shared_ptr<PrivateKey>(new PrivateKey(key, keyLen));
112-
setRSACert(_axtls_chain.get(), _axtls_sk.get());
113-
}
114-
115-
void WiFiServerSecure::setServerKeyAndCert_P(const uint8_t *key, int keyLen, const uint8_t *cert, int certLen) {
116-
setServerKeyAndCert(key, keyLen, cert, certLen);
117-
}
118-
119-
120104
};

libraries/ESP8266WiFi/src/WiFiServerSecureBearSSL.h

-8
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@ class WiFiServerSecure : public WiFiServer {
5858
// If awaiting connection available and authenticated (i.e. client cert), return it.
5959
WiFiClientSecure available(uint8_t* status = NULL);
6060

61-
// Compatibility with axTLS interface
62-
void setServerKeyAndCert(const uint8_t *key, int keyLen, const uint8_t *cert, int certLen);
63-
void setServerKeyAndCert_P(const uint8_t *key, int keyLen, const uint8_t *cert, int certLen);
64-
6561
WiFiServerSecure& operator=(const WiFiServerSecure&) = default;
6662

6763
using ClientType = WiFiClientSecure;
@@ -74,10 +70,6 @@ class WiFiServerSecure : public WiFiServer {
7470
int _iobuf_out_size = 837;
7571
const X509List *_client_CA_ta = nullptr;
7672

77-
// axTLS compat
78-
std::shared_ptr<X509List> _axtls_chain;
79-
std::shared_ptr<PrivateKey> _axtls_sk;
80-
8173
};
8274

8375
};

tests/device/test_sw_http_client/test_sw_http_client.ino

-38
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include <Arduino.h>
22
#include <ESP8266WiFi.h>
33
#include <ESP8266HTTPClient.h>
4-
#include <WiFiClientSecureAxTLS.h>
54
#include <BSTest.h>
65
#include <pgmspace.h>
76

@@ -210,43 +209,6 @@ TEST_CASE("HTTPS GET request", "[HTTPClient]")
210209
}
211210
}
212211
}
213-
//
214-
// Same tests with axTLS
215-
//
216-
#if !CORE_MOCK
217-
{
218-
// small request
219-
#pragma GCC diagnostic push
220-
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
221-
axTLS::WiFiClientSecure client;
222-
#pragma GCC diagnostic pop
223-
HTTPClient http;
224-
http.begin(client, getenv("SERVER_IP"), 8088, "/", fp);
225-
auto httpCode = http.GET();
226-
REQUIRE(httpCode == HTTP_CODE_OK);
227-
String payload = http.getString();
228-
REQUIRE(payload == "hello!!!");
229-
}
230-
{
231-
// request which returns 4000 bytes
232-
#pragma GCC diagnostic push
233-
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
234-
axTLS::WiFiClientSecure client;
235-
#pragma GCC diagnostic pop
236-
HTTPClient http;
237-
http.begin(client, getenv("SERVER_IP"), 8088, "/data?size=4000", fp);
238-
auto httpCode = http.GET();
239-
REQUIRE(httpCode == HTTP_CODE_OK);
240-
String payload = http.getString();
241-
auto len = payload.length();
242-
REQUIRE(len == 4000);
243-
for (size_t i = 0; i < len; ++i) {
244-
if (payload[i] != 'a') {
245-
REQUIRE(false);
246-
}
247-
}
248-
}
249-
#endif
250212
}
251213

252214
void loop()

0 commit comments

Comments
 (0)