爱普生 TM-T88V-i 摘要式身份验证不起作用

Epson TM-T88V-i digest authentication not working

我的 Epson TM-T88V-i 收据打印机试图从服务器 URL 获取 XML 数据,这需要打印机通过 HTTP 摘要进行身份验证。 (此 Epson 功能称为“Server Direct Print”)

我可以从打印机的 Web 控制台向服务器发送测试请求,但 HTTP 摘要身份验证失败。如果我让打印机尝试在服务器上进行身份验证,也会发生同样的情况。

如果我尝试通过浏览器访问 URL,则会出现 HTTP 摘要用户名+密码框,如果我输入凭据,XML 会按预期显示在浏览器中。这表明服务器端的 HTTP 摘要机制设置正确(我使用的是 PHP 框架 Symfony 2.8)。

在服务器端,我看到以下日志信息:

Step 1
[2016-04-03 16:33:01] security.INFO: An AuthenticationException was thrown; redirecting to authentication entry point. {"exception":"[object] (Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException(code: 0): A Token was not found in the TokenStorage. at /home/.../src/Symfony/Component/Security/Http/Firewall/AccessListener.php:53)"}


Step 2
[2016-04-03 16:33:01] security.DEBUG: Calling Authentication entry point.


Step 3
[2016-04-03 16:33:01] security.DEBUG: Digest Authorization header received from user agent. {"header":"username=\"printer\", realm=\"example\", nonce=\"MTQ1OTk5Mzk4MS40NjQ3OmI0OTVmN2ZkZTlhYmE1NmNjNDIxNmIxMWU0OGVmYjUz\", uri=\"/export\", cnonce=\"MDAxNjM0\", nc=00000001, qop=\"auth\", response=\"c6ad88607624efd17f7de602f6ee9def\""}
Step 4
[2016-04-03 16:33:01] security.DEBUG: Unexpected response from the DigestAuth received; is the header returning a clear text passwords? {"expected":"741bff6abed513b6948c26eae529b6b6","received":"c6ad88607624efd17f7de602f6ee9def"}


Step 5
[2016-04-03 16:33:01] security.INFO: Digest authentication failed. {"exception":"[object] (Symfony\Component\Security\Core\Exception\BadCredentialsException(code: 0): Incorrect response at /home/.../src/Symfony/Component/Security/Http/Firewall/DigestAuthenticationListener.php:107)"}

日志文件告诉我们服务器端发生了什么:

  1. 在步骤 1+2 中,Epson 尝试访问受 HTTP 摘要保护的服务器 URL,服务器发送带有随机数的 401 "unauthorized" 响应(我们不在这个日志文件中看不到这个)

  2. 在第 3 步中,爱普生发送包含所有必要数据的 HTTP 摘要客户端授权请求。 response 参数包含一个哈希 should 从其他授权参数

  3. 中生成
  4. 在第 4 步中,我的 symfony 2.8 应用程序说,在第 3 步中由 Epson 发送的散列响应参数不是 HTTP 摘要过程所期望的参数。

  5. 第 5 步最后显示,HTTP 摘要认证失败。

据我了解,摘要式身份验证过程(如 wikipedia 中所述)是正确的,只是 Epson 未在其身份验证请求中计算正确的哈希值。

有谁知道为什么 Epson 发送错误的 response 参数或者有人让这个场景起作用?

经过2天的调试,我终于解决了这个问题。我的摘要身份验证密码的长度是 40 个字符。我减少了大约 20 个字符。不行,dohhh。