[英]OnVif integration error - unauthorized with client authentication scheme 'Digest'
使用此代碼連接到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="Our Site"
的請求添加Http標頭WWW-Authenticate
。 但是沒有運氣。
那是什么呀? 如何解決?
您可能無法處理摘要身份驗證 。 為了正確處理事情,您應該將請求發送到非PRE_AUTH
ONVIF方法,而不使用摘要(摘要)或ws-usernameToken。
您可以獲得以下兩個答案之一:
您會收到帶有env:Sender ter:NoAuthorized
的500響應,這意味着攝像機不支持HTTP摘要(實際上,對於配置文件S設備不是強制性的)。 在這種情況下,您只需要使用WS-UsernameToken
您會從設備收到帶有WWW-Authenticate
標頭的401響應。 在這種情況下,您應該遵循RFC 2617 ,評估所有必要的元素,然后使用Authorization
標頭重新發送您的請求。
請記住,HTTP摘要挑戰總是由攝像機啟動的,您不能僅將其添加到第一個請求中。
檢查Core規范的第5.12節,至少要知道有一個攝像機處理身份驗證。
我遇到了一個相關問題 -我必須使用我不知道身份驗證HTTP身份驗證模式(基本/摘要)的ONVIF攝像機進行身份驗證。 在我的答案中,您可以看到如何正確地遍歷所有HTTP身份驗證方案,或者可以僅使用Digest的代碼,希望對您有所幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.