【问题标题】:OnVif integration error - unauthorized with client authentication scheme 'Digest'OnVif 集成错误 - 未经授权使用客户端身份验证方案“摘要”
【发布时间】:2015-06-05 11:00:28
【问题描述】:

在 C# .Net 4.5 中使用 this code 连接到我的 IP 摄像机上的 OnVif 服务。
在该代码旁边,我正在尝试获取设备信息,如下所示:

string str = client.GetDeviceInformation(out model, out firmware, out serial, out hardwareId);

并遇到此错误:

An exception of type 'System.ServiceModel.Security.MessageSecurityException' occurred in mscorlib.dll but was not handled in user code

Additional information: The HTTP request is unauthorized with client authentication scheme 'Digest'. The authentication header received from the server was 'Basic realm="CBBA"'.

我试过this information about Basic realm。通过将 Http 标头 WWW-Authenticate 添加到值为 Basic realm="Our Site" 的请求中。但没有运气。

那是什么鬼?如何解决?

【问题讨论】:

  • 请不要在标题中包含语言标签,除非没有它就没有意义。标记用于此目的。
  • 感谢您的建议

标签: c# ip-camera digest-authentication onvif


【解决方案1】:

您可能无法处理Digest Authentication。要正确处理事情,您应该向非PRE_AUTH ONVIF 方法发送请求,而不使用身份验证、digest 和 ws-usernameToken。

您可以得到以下两个答案之一:

  1. 您会收到带有 env:Sender ter:NoAuthorized 的 500 响应,这意味着相机不支持 HTTP 摘要(事实上,对于配置文件 S 设备,这不是强制性的)。在这种情况下,您必须只使用 WS-UsernameToken

  2. 您会从设备收到带有 WWW-Authenticate 标头的 401 响应。在这种情况下,您应该遵循RFC 2617,评估所有必要元素并使用Authorization 标头重新发送您的请求。

请记住,HTTP 摘要挑战始终由相机启动,您不能只将其添加到第一个请求中。

查看Core specification 的§5.12,至少知道有一个摄像头处理身份验证。

【讨论】:

    【解决方案2】:

    我有一个relevant issue - 我必须使用我不知道身份验证 HTTP 身份验证模式(基本/摘要)的 ONVIF 摄像机进行身份验证。在我的回答中,您可以看到如何正确遍历所有 HTTP 身份验证方案,或者您可以只获取摘要的代码,希望对您有所帮助。

    【讨论】:

      猜你喜欢
      • 2012-09-24
      • 2011-06-22
      • 2012-04-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-27
      • 2011-01-16
      相关资源
      最近更新 更多