Skip to content
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

Update DigestAuthorization.ino (Simple example update) #7579

Merged
merged 3 commits into from
Sep 4, 2020
Merged
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ String getCNonce(const int len) {
return s;
}

String getDigestAuth(String& authReq, const String& username, const String& password, const String& uri, unsigned int counter) {
String getDigestAuth(String& authReq, const String& username, const String& password, const String& method, const String& uri, unsigned int counter) {
// extracting required parameters for RFC 2069 simpler Digest
String realm = exractParam(authReq, "realm=\"", '"');
String nonce = exractParam(authReq, "nonce=\"", '"');
Expand All @@ -64,7 +64,7 @@ String getDigestAuth(String& authReq, const String& username, const String& pass
String h1 = md5.toString();

md5.begin();
md5.add(String("GET:") + uri);
md5.add(method + ":" + uri);
md5.calculate();
String h2 = md5.toString();

Expand All @@ -81,6 +81,7 @@ String getDigestAuth(String& authReq, const String& username, const String& pass
}

void setup() {
randomSeed(RANDOM_REG32);
Serial.begin(115200);

WiFi.mode(WIFI_STA);
Expand Down Expand Up @@ -118,7 +119,7 @@ void loop() {
String authReq = http.header("WWW-Authenticate");
Serial.println(authReq);

String authorization = getDigestAuth(authReq, String(username), String(password), String(uri), 1);
String authorization = getDigestAuth(authReq, String(username), String(password), "GET", String(uri), 1);

http.end();
http.begin(client, String(server) + String(uri));
Expand Down