使用 'digest authentication' 的 --digest 选项和 linux 中的 curl

Using --digest option for 'digest authentication' with curl in linux

我正在尝试使用 linux 中的 curl 更改基于 Onvif 的相机的日期。我已经在 c# 中成功完成并使用摘要身份验证,但我被困在这种情况下。

我正在使用以下命令:

curl -u "admin:admin" --digest http://10.104.37.1:80/onvif/device_service --data '<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><SetSystemDateAndTime xmlns="http://www.onvif.org/ver10/device/wsdl"><DateTimeType>Manual</DateTimeType><DaylightSavings>false</DaylightSavings><TimeZone><TZ xmlns="http://www.onvif.org/ver10/schema">CST-0:00:00</TZ></TimeZone><UTCDateTime><Time xmlns="http://www.onvif.org/ver10/schema"><Hour>8</Hour><Minute>8</Minute><Second>8</Second></Time><Date xmlns="http://www.onvif.org/ver10/schema"><Year>2008</Year><Month>8</Month><Day>8</Day></Date></UTCDateTime></SetSystemDateAndTime></s:Body></s:Envelope>'

我得到了以下结果(似乎卡住了):

  • About to connect() to 10.104.37.1 port 80 (#0)
  • Trying 10.104.37.1... connected
  • Connected to 10.104.37.1 (10.104.37.1) port 80 (#0)
  • Server auth using Digest with user 'admin'
  • POST /onvif/device_service HTTP/1.1
  • User-Agent: curl/7.19.7 (i486-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15
  • Host: 10.104.37.1
  • Accept: /
  • Content-Length: 0
  • Content-Type: application/x-www-form-urlencoded

在此之后,什么也没有发生。

不得不说,如果我只是读取日期(这个动作不需要auth)...

curl -u admin:admin http://10.104.37.1:80/onvif/device_service --data '<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><GetSystemDateAndTime xmlns="http://www.onvif.org/ver10/device/wsdl"/></s:Body></s:Envelope>' 

...它正确执行,但如果我添加“--digest”,该过程将遵循之前评论的行为。

谁能给我提示?

谢谢!

编辑: 内容length=0是不是很奇怪?

我终于找到了这个问题的解决方案:我在完整命令中添加了选项--anyauth。 无论如何,我仍然不知道为什么使用 --digest 选项会卡住进程。