在linux中使用--digest选项来使用curl进行“摘要认证” [英] Using --digest option for 'digest authentication' with curl in linux
问题描述
我想在linux中使用curl更改基于Onvif的摄像机的日期。
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.
我正在使用以下命令:
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):
- 关于连接()到10.104.37.1端口80(#0)
- 尝试10.104.37.1 ...连接
- 连接到10.104.37.1(10.104.37.1)端口80(#0)
- 使用用户'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
- 主机:10.104.37.1
- 接受:
- Content-Length:0
- Content-Type:application / x-www-form-urlencoded
- 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)...
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>'
...它正确,但如果我添加--digest,该过程遵循之前评论的行为。
...it does it correctly, but if I add the "--digest", the process follows the behaviour commented before.
任何人可以给我一个提示?
Anyone can give me a hint?
谢谢!
EDIT:
我很遗憾,内容长度= 0?
Isnt it strange that the content length=0?
推荐答案
我终于找到了解决方案这个问题:我添加了选项 - anyauth 到完整的命令。
无论如何,我仍然不知道为什么使用--digest选项卡住了进程。
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.
这篇关于在linux中使用--digest选项来使用curl进行“摘要认证”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!