-
Notifications
You must be signed in to change notification settings - Fork 13.3k
make HTTP Update Server more secure #2104
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
305d060
Merge remote-tracking branch 'esp8266/master'
e9a5c48
Merge remote-tracking branch 'esp8266/master'
246edd3
Merge remote-tracking branch 'esp8266/master'
c130c17
Merge remote-tracking branch 'esp8266/master'
617206d
Merge remote-tracking branch 'esp8266/master'
039f4db
Merge remote-tracking branch 'esp8266/master'
e6578b4
Merge remote-tracking branch 'esp8266/master'
b3fe814
make HTTP Update Server more secure
c6e4efc
move to overloaded setup
7e2d1fa
remove delay in both examples
a8637bd
Get better result responses
564019c
fix strings
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
libraries/ESP8266HTTPUpdateServer/examples/SecureWebUpdater/SecureWebUpdater.ino
This file contains hidden or 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,45 @@ | ||
/* | ||
To upload through terminal you can use: curl -F "[email protected]" esp8266-webupdate.local/update | ||
*/ | ||
|
||
#include <ESP8266WiFi.h> | ||
#include <WiFiClient.h> | ||
#include <ESP8266WebServer.h> | ||
#include <ESP8266mDNS.h> | ||
#include <ESP8266HTTPUpdateServer.h> | ||
|
||
const char* host = "esp8266-webupdate"; | ||
const char* update_path = "/firmware"; | ||
const char* update_username = "admin"; | ||
const char* update_password = "admin"; | ||
const char* ssid = "........"; | ||
const char* password = "........"; | ||
|
||
ESP8266WebServer httpServer(80); | ||
ESP8266HTTPUpdateServer httpUpdater; | ||
|
||
void setup(void){ | ||
|
||
Serial.begin(115200); | ||
Serial.println(); | ||
Serial.println("Booting Sketch..."); | ||
WiFi.mode(WIFI_AP_STA); | ||
WiFi.begin(ssid, password); | ||
|
||
while(WiFi.waitForConnectResult() != WL_CONNECTED){ | ||
WiFi.begin(ssid, password); | ||
Serial.println("WiFi failed, retrying."); | ||
} | ||
|
||
MDNS.begin(host); | ||
|
||
httpUpdater.setup(&httpServer, update_path, update_username, update_password); | ||
httpServer.begin(); | ||
|
||
MDNS.addService("http", "tcp", 80); | ||
Serial.printf("HTTPUpdateServer ready! Open http://%s.local%s in your browser and login with username '%s' and password '%s'\n", host, update_path, update_username, update_password); | ||
} | ||
|
||
void loop(void){ | ||
httpServer.handleClient(); | ||
} |
This file contains hidden or 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 |
---|---|---|
|
@@ -39,5 +39,4 @@ void setup(void){ | |
|
||
void loop(void){ | ||
httpServer.handleClient(); | ||
delay(1); | ||
} |
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@igrr you think maybe we should not reboot if Update failed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll merge this as is, let's address this in a separate pull request. I think a good idea would be to add update callbacks similar to ESP8266HTTPUpdate (client). Actually maybe we need to review APIs of HTTP update client and HTTP update server and make them more uniform. Let's discuss further on gitter.