forked from espressif/arduino-esp32
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add WiFiClientSecure::setInsecure() to equalize API with ESP8266 (esp…
- Loading branch information
Showing
6 changed files
with
106 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
libraries/WiFiClientSecure/examples/WiFiClientInsecure/WiFiClientInsecure.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#include <WiFiClientSecure.h> | ||
|
||
const char* ssid = "your-ssid"; // your network SSID (name of wifi network) | ||
const char* password = "your-password"; // your network password | ||
|
||
const char* server = "www.howsmyssl.com"; // Server URL | ||
|
||
WiFiClientSecure client; | ||
|
||
void setup() { | ||
//Initialize serial and wait for port to open: | ||
Serial.begin(115200); | ||
delay(100); | ||
|
||
Serial.print("Attempting to connect to SSID: "); | ||
Serial.println(ssid); | ||
WiFi.begin(ssid, password); | ||
|
||
// attempt to connect to Wifi network: | ||
while (WiFi.status() != WL_CONNECTED) { | ||
Serial.print("."); | ||
// wait 1 second for re-trying | ||
delay(1000); | ||
} | ||
|
||
Serial.print("Connected to "); | ||
Serial.println(ssid); | ||
|
||
Serial.println("\nStarting connection to server..."); | ||
client.setInsecure();//skip verification | ||
if (!client.connect(server, 443)) | ||
Serial.println("Connection failed!"); | ||
else { | ||
Serial.println("Connected to server!"); | ||
// Make a HTTP request: | ||
client.println("GET https://www.howsmyssl.com/a/check HTTP/1.0"); | ||
client.println("Host: www.howsmyssl.com"); | ||
client.println("Connection: close"); | ||
client.println(); | ||
|
||
while (client.connected()) { | ||
String line = client.readStringUntil('\n'); | ||
if (line == "\r") { | ||
Serial.println("headers received"); | ||
break; | ||
} | ||
} | ||
// if there are incoming bytes available | ||
// from the server, read them and print them: | ||
while (client.available()) { | ||
char c = client.read(); | ||
Serial.write(c); | ||
} | ||
|
||
client.stop(); | ||
} | ||
} | ||
|
||
void loop() { | ||
// do nothing | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters