11
11
12
12
#include < string>
13
13
#include < stdint.h>
14
- #include < WiFiClientSecure.h>
14
+
15
+ #if (defined(ESP32) && ESP_ARDUINO_VERSION_MAJOR >= 3)
16
+ #define ksCertUtilsNetCLientSecure_t NetworkClientSecure
17
+ #else
18
+ #define ksCertUtilsNetCLientSecure_t WiFiClientSecure
19
+ #endif
20
+
21
+ class ksCertUtilsNetCLientSecure_t ;
15
22
16
23
namespace ksf ::misc
17
24
{
@@ -34,25 +41,30 @@ namespace ksf::misc
34
41
bool fingerprintToBytes (const std::string& fingerprint, uint8_t * bytes, uint8_t bytesLen) const ;
35
42
36
43
public:
44
+ /* !
45
+ @brief Constructor.
46
+ */
47
+ ksCertFingerprint ();
48
+
37
49
/* !
38
50
@brief Destructor.
39
51
*/
40
52
virtual ~ksCertFingerprint ();
41
53
42
54
/* !
43
55
@brief Performs certificate fingerprint setup (platform dependent).
44
- @param client Pointer of WiFiClientSecure
56
+ @param client Pointer of ksCertUtilsNetCLientSecure_t
45
57
@param fingerprint Fingerprint string
46
58
@return True if setup has been successfull, otherwise false.
47
59
*/
48
- virtual bool setup (WiFiClientSecure * client, const std::string& fingerprint);
60
+ virtual bool setup (ksCertUtilsNetCLientSecure_t * client, const std::string& fingerprint) = 0 ;
49
61
50
62
/* !
51
63
@brief Performs certificate fingerprint validation (platform dependent).
52
- @param client Pointer of WiFiClientSecure
64
+ @param client Pointer of ksCertUtilsNetCLientSecure_t
53
65
@return True on verification pass, otherwise false.
54
66
*/
55
- virtual bool verify (WiFiClientSecure * client) const ;
67
+ virtual bool verify (ksCertUtilsNetCLientSecure_t * client) const = 0 ;
56
68
};
57
69
58
70
#ifdef ESP32
@@ -67,18 +79,18 @@ namespace ksf::misc
67
79
68
80
On ESP32 it will copy fingerprint into fingerprintBytes.
69
81
70
- @param client Pointer to WiFiClientSecure
82
+ @param client Pointer to ksCertUtilsNetCLientSecure_t
71
83
@param fingerprint Fingerprint string
72
84
@return True if setup passed, otherwise false.
73
85
*/
74
- bool setup (WiFiClientSecure * client, const std::string& fingerprint) override ;
86
+ bool setup (ksCertUtilsNetCLientSecure_t * client, const std::string& fingerprint) override ;
75
87
76
88
/* !
77
89
@brief Converts bytes into a string and performs fingerprint validation.
78
- @param client Pointer to WiFiClientSecure
90
+ @param client Pointer to ksCertUtilsNetCLientSecure_t
79
91
@return True if verification passed, otherwise false.
80
92
*/
81
- bool verify (WiFiClientSecure * client) const override ;
93
+ bool verify (ksCertUtilsNetCLientSecure_t * client) const override ;
82
94
};
83
95
84
96
using ksCertFingerprintHolder = ksCertFingerprintESP32;
@@ -90,21 +102,21 @@ namespace ksf::misc
90
102
public:
91
103
/* !
92
104
@brief Performs fingerprint setup (platform dependent).
93
- @param client Pointer of WiFiClientSecure .
105
+ @param client Pointer of ksCertUtilsNetCLientSecure_t .
94
106
@param fingerprint Fingerprint string.
95
107
@return True if setup passed, otherwise false.
96
108
*/
97
- bool setup (WiFiClientSecure * client, const std::string& fingerprint) override ;
109
+ bool setup (ksCertUtilsNetCLientSecure_t * client, const std::string& fingerprint) override ;
98
110
99
111
/* !
100
112
@brief Converts bytes into a string and performs fingerprint validation.
101
113
102
114
Always returns true on ESP8266 as this functionality is handled under the hood.
103
115
104
- @param client Pointer to WiFiClientSecure
116
+ @param client Pointer to ksCertUtilsNetCLientSecure_t
105
117
@return Always true in case of ESP8266.
106
118
*/
107
- bool verify (WiFiClientSecure * client) const override ;
119
+ bool verify (ksCertUtilsNetCLientSecure_t * client) const override ;
108
120
};
109
121
110
122
using ksCertFingerprintHolder = ksCertFingerprintESP8266;
0 commit comments