http - 在 linux 中对 'digest authentication' 使用 --digest 选项和 curl

标签 http curl http-authentication digest-authentication onvif

我正在尝试在 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

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

我不得不说,如果我只是读取日期(这个 Action 不需要授权)...

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”,该过程将遵循之前评论的行为。

谁能给我一个提示?

谢谢!

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

最佳答案

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

关于http - 在 linux 中对 'digest authentication' 使用 --digest 选项和 curl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35846324/

相关文章:

java - 服务器监听多个端口 [Java]

Node.JS:处理后数据读取错误的正确方法是什么?

php - 如何安全连接以获得安全 cookie

php - 使用 PHP 手动解析原始多部分/表单数据数据

android - 使用基本 HTTP 身份验证 : "Cannot retry streamed HTTP body" 改造 POST 请求

html - 如何在 html 中设置页面缓存?

http - RESTful 建议 : default value for given resource

通过C程序复制一个文件到HTTP Server

android - Android 中 HttpURLConnection 的 HTTP 身份验证

javascript - jQuery ajax 基本身份验证不起作用