From 2d3c57635d6ef7d180a1e292e5e6d8b467228afa Mon Sep 17 00:00:00 2001 From: me-no-dev Date: Fri, 19 Mar 2021 02:10:16 +0200 Subject: [PATCH] Fix: WebServer: Digest authentication failed for some clients Ports: https://github.com/esp8266/Arduino/pull/5506/commits/4d3850e87ee2cdd7ee4a79fb791a4ebbaa522487 --- libraries/WebServer/src/WebServer.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libraries/WebServer/src/WebServer.cpp b/libraries/WebServer/src/WebServer.cpp index 027d2464..9b29f3e2 100644 --- a/libraries/WebServer/src/WebServer.cpp +++ b/libraries/WebServer/src/WebServer.cpp @@ -33,7 +33,8 @@ static const char AUTHORIZATION_HEADER[] = "Authorization"; -static const char qop_auth[] = "qop=\"auth\""; +static const char qop_auth[] PROGMEM = "qop=auth"; +static const char qop_auth_quoted[] PROGMEM = "qop=\"auth\""; static const char WWW_Authenticate[] = "WWW-Authenticate"; static const char Content_Length[] = "Content-Length"; @@ -185,7 +186,7 @@ bool WebServer::authenticate(const char * username, const char * password){ } // parameters for the RFC 2617 newer Digest String _nc,_cnonce; - if(authReq.indexOf(FPSTR(qop_auth)) != -1) { + if(authReq.indexOf(FPSTR(qop_auth)) != -1 || authReq.indexOf(FPSTR(qop_auth_quoted)) != -1) { _nc = _extractParam(authReq, F("nc="), ','); _cnonce = _extractParam(authReq, F("cnonce=\""),'\"'); } @@ -205,7 +206,7 @@ bool WebServer::authenticate(const char * username, const char * password){ } log_v("Hash of GET:uri=%s", _H2.c_str()); String _responsecheck = ""; - if(authReq.indexOf(FPSTR(qop_auth)) != -1) { + if(authReq.indexOf(FPSTR(qop_auth)) != -1 || authReq.indexOf(FPSTR(qop_auth_quoted)) != -1) { _responsecheck = md5str(_H1 + ':' + _nonce + ':' + _nc + ':' + _cnonce + F(":auth:") + _H2); } else { _responsecheck = md5str(_H1 + ':' + _nonce + ':' + _H2);