0

使用此代码在 C# .Net 4.5 中连接到我的 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"'.

我尝试了有关 Basic realm的信息。WWW-Authenticate通过向带有 value 的请求添加 Http 标头Basic realm="Our Site"。但没有运气。

那是什么呀?如何解决?

4

2 回答 2

0

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

于 2014-02-28T13:22:28.713 回答
0

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

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

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

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

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

检查 §5.12 of the Core specification,至少要知道有一个相机处理身份验证。

于 2014-02-26T13:59:01.087 回答