Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
arduino-esp32
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
arduino-esp32
Commits
65c861ad
Commit
65c861ad
authored
Nov 19, 2018
by
lbernstone
Committed by
Me No Dev
Nov 19, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added loadCert methods to WiFiClientSecure (#1959)
parent
f6a71da3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
0 deletions
+51
-0
libraries/WiFiClientSecure/src/WiFiClientSecure.cpp
libraries/WiFiClientSecure/src/WiFiClientSecure.cpp
+45
-0
libraries/WiFiClientSecure/src/WiFiClientSecure.h
libraries/WiFiClientSecure/src/WiFiClientSecure.h
+6
-0
No files found.
libraries/WiFiClientSecure/src/WiFiClientSecure.cpp
View file @
65c861ad
...
...
@@ -230,6 +230,51 @@ bool WiFiClientSecure::verify(const char* fp, const char* domain_name)
return
verify_ssl_fingerprint
(
sslclient
,
fp
,
domain_name
);
}
char
*
WiFiClientSecure
::
_streamLoad
(
Stream
&
stream
,
size_t
size
)
{
char
*
dest
=
(
char
*
)
malloc
(
size
);
if
(
!
dest
)
{
return
nullptr
;
}
if
(
size
!=
stream
.
readBytes
(
dest
,
size
))
{
free
(
dest
);
return
nullptr
;
}
char
ret
[
size
+
1
];
snprintf
(
ret
,
size
,
"%s"
,
dest
);
free
(
dest
);
return
ret
;
}
bool
WiFiClientSecure
::
loadCACert
(
Stream
&
stream
,
size_t
size
)
{
char
*
dest
=
_streamLoad
(
stream
,
size
);
bool
ret
=
false
;
if
(
dest
)
{
setCACert
(
dest
);
ret
=
true
;
}
return
ret
;
}
bool
WiFiClientSecure
::
loadCertificate
(
Stream
&
stream
,
size_t
size
)
{
char
*
dest
=
_streamLoad
(
stream
,
size
);
bool
ret
=
false
;
if
(
dest
)
{
setCertificate
(
dest
);
ret
=
true
;
}
return
ret
;
}
bool
WiFiClientSecure
::
loadPrivateKey
(
Stream
&
stream
,
size_t
size
)
{
char
*
dest
=
_streamLoad
(
stream
,
size
);
bool
ret
=
false
;
if
(
dest
)
{
setPrivateKey
(
dest
);
ret
=
true
;
}
return
ret
;
}
int
WiFiClientSecure
::
lastError
(
char
*
buf
,
const
size_t
size
)
{
if
(
!
_lastError
)
{
...
...
libraries/WiFiClientSecure/src/WiFiClientSecure.h
View file @
65c861ad
...
...
@@ -58,6 +58,9 @@ public:
void
setCACert
(
const
char
*
rootCA
);
void
setCertificate
(
const
char
*
client_ca
);
void
setPrivateKey
(
const
char
*
private_key
);
bool
loadCACert
(
Stream
&
stream
,
size_t
size
);
bool
loadCertificate
(
Stream
&
stream
,
size_t
size
);
bool
loadPrivateKey
(
Stream
&
stream
,
size_t
size
);
bool
verify
(
const
char
*
fingerprint
,
const
char
*
domain_name
);
operator
bool
()
...
...
@@ -84,6 +87,9 @@ public:
return
sslclient
->
socket
=
-
1
;
}
private:
char
*
_streamLoad
(
Stream
&
stream
,
size_t
size
);
//friend class WiFiServer;
using
Print
::
write
;
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment