Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix and simplify sni setting#987

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
pennam merged 1 commit intoarduino:mainfrompennam:sni-fix
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletionslibraries/SocketWrapper/src/AClient.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -46,11 +46,11 @@ int arduino::AClient::connectSSL(IPAddress ip, uint16_t port) {
return client->connectSSL(ip, port);
}

int arduino::AClient::connectSSL(const char *host, uint16_t port, bool disableSNI) {
int arduino::AClient::connectSSL(const char *host, uint16_t port) {
if (!client) {
newMbedClient();
}
return client->connectSSL(host, port, disableSNI);
return client->connectSSL(host, port);
}

void arduino::AClient::stop() {
Expand Down
2 changes: 1 addition & 1 deletionlibraries/SocketWrapper/src/AClient.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,7 +32,7 @@ class AClient : public Client {
virtual int connect(IPAddress ip, uint16_t port);
virtual int connect(const char *host, uint16_t port);
int connectSSL(IPAddress ip, uint16_t port);
int connectSSL(const char* host, uint16_t port, bool disableSNI = false);
int connectSSL(const char* host, uint16_t port);
virtual void stop();

virtual explicit operator bool();
Expand Down
10 changes: 1 addition & 9 deletionslibraries/SocketWrapper/src/MbedClient.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -186,15 +186,7 @@ int arduino::MbedClient::connectSSL(IPAddress ip, uint16_t port) {
return connectSSL(SocketHelpers::socketAddressFromIpAddress(ip, port));
}

int arduino::MbedClient::connectSSL(const char *host, uint16_t port, bool disableSNI) {
if (!disableSNI) {
if (sock == nullptr) {
sock = new TLSSocket();
_own_socket = true;
}
static_cast<TLSSocket *>(sock)->set_hostname(host);
}

int arduino::MbedClient::connectSSL(const char *host, uint16_t port) {
SocketAddress socketAddress = SocketAddress();
socketAddress.set_port(port);
SocketHelpers::gethostbyname(getNetwork(), host, &socketAddress);
Expand Down
2 changes: 1 addition & 1 deletionlibraries/SocketWrapper/src/MbedClient.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -56,7 +56,7 @@ class MbedClient {
virtual int connect(const char* host, uint16_t port);
int connectSSL(SocketAddress socketAddress);
int connectSSL(IPAddress ip, uint16_t port);
int connectSSL(const char* host, uint16_t port, bool disableSNI = false);
int connectSSL(const char* host, uint16_t port);
size_t write(uint8_t);
size_t write(const uint8_t* buf, size_t size);
int available();
Expand Down
8 changes: 7 additions & 1 deletionlibraries/SocketWrapper/src/MbedSSLClient.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -41,7 +41,8 @@ class MbedSSLClient : public arduino::MbedClient {
return connectSSL(ip, port);
}
int connect(const char* host, uint16_t port) {
return connectSSL(host, port, _disableSNI);
_hostname = host;
return connectSSL(host, port);
}
void disableSNI(bool statusSNI) {
_disableSNI = statusSNI;
Expand All@@ -53,6 +54,7 @@ class MbedSSLClient : public arduino::MbedClient {

protected:
const char* _ca_cert_custom = NULL;
const char* _hostname = NULL;

private:
int setRootCA() {
Expand All@@ -79,6 +81,10 @@ class MbedSSLClient : public arduino::MbedClient {
}
#endif

if(_hostname && !_disableSNI) {
((TLSSocket*)sock)->set_hostname(_hostname);
}

if(_ca_cert_custom != NULL) {
err = ((TLSSocket*)sock)->append_root_ca_cert(_ca_cert_custom);
}
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp