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

99封情书 提交于 2019-12-23 17:15:33

问题


I am trying to change the date of an Onvif based camera using curl in linux. I have already succeded doing it in c# and using digest authentication, but I am stuck in this case.

I am using the following command:

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>'

And I am obtaining the following result (it seems to get stuck):

  • 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

After this, nothing happens.

I have to say that if I just read the date (this action does not need 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>' 

...it does it correctly, but if I add the "--digest", the process follows the behaviour commented before.

Anyone can give me a hint?

Thanks!

EDIT: Isnt it strange that the content length=0?


回答1:


I have finally found a solution to this problem: I added the option --anyauth to the full command. Anyway, I still do not know why using --digest option stucks the process.



来源:https://stackoverflow.com/questions/35846324/using-digest-option-for-digest-authentication-with-curl-in-linux

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!