Tôi đã quay camera SNC-CH110 từ Sony. Người dùng mặc định là 'admin' và mật khẩu là 'admin'. Vấn đề lớn của tôi là xác thực.ONVIF: Lỗi xác thực với SNC-CH110 bằng giao thức ONVIF
<SOAP-ENV:Fault>
<SOAP-ENV:Code>
<SOAP-ENV:Value>SOAP-ENV:Sender</SOAP-ENV:Value>
<SOAP-ENV:Subcode>
<SOAP-ENV:Value>ter:NotAuthorized</SOAP-ENV:Value>
</SOAP-ENV:Subcode>
</SOAP-ENV:Code>
<SOAP-ENV:Reason>
<SOAP-ENV:Text xml:lang="en">Sender not Authorized</SOAP-ENV:Text>
</SOAP-ENV:Reason>
<SOAP-ENV:Detail>
<SOAP-ENV:Text xml:lang="en">The action requested requires authorization and the sender is not authorized
</SOAP-ENV:Text>
</SOAP-ENV:Detail>
</SOAP-ENV:Fault>
Theo ONVIF đặc điểm kỹ thuật 1,02, tôi sử dụng “tên người dùng hồ sơ thẻ” để xác thực được mô tả trong đặc tả http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0.pdf hoặc trong http://www.onvif.org/Portals/0/documents/WhitePapers/ONVIF_WG-APG-Application_Programmer%27s_Guide.pdf
Dưới đây là Script mà tôi sử dụng để tạo yêu cầu xà phòng:
<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
xmlns:tds="http://www.onvif.org/ver10/device/wsdl">
<SOAP-ENV:Header>
<Security SOAP-ENV:mustUnderstand="1" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<UsernameToken>
<Username>admin</Username>
<wsse:Password Type=""http://docs.oasis-open.org/wss/2004/01/oasis-200401-wssusername-token-profile-1.0#PasswordDigest"">" + hashBase64 + @"</wsse:Password>
<wsse:Nonce >" + Convert.ToBase64String(_nonce) + @"</wsse:Nonce>
<Created>" + dt + @"</Created>
</UsernameToken>
</Security>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<tds:GetCapabilities>
<tds:Category>All</tds:Category>
</tds:GetCapabilities>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>"
đây là mã của tôi để gửi yêu cầu:
byte[] _nonce = new byte[16];
RandomNumberGenerator rndGenerator = new RNGCryptoServiceProvider();
rndGenerator.GetBytes(_nonce);
// get other operands to the right format
string dt = DateTime.UtcNow.ToString("yyyy-MM-ddThh:mm:ss.fffZ");
byte[] time = Encoding.UTF8.GetBytes(dt);
byte[] pwd = Encoding.UTF8.GetBytes("admin");
byte[] operand = new byte[_nonce.Length + time.Length + pwd.Length];
Array.Copy(_nonce, operand, _nonce.Length);
Array.Copy(time, 0, operand, _nonce.Length, time.Length);
Array.Copy(pwd, 0, operand, _nonce.Length + time.Length, pwd.Length);
// create the hash
SHA1 sha1 = SHA1.Create();
string hashBase64 = Convert.ToBase64String(sha1.ComputeHash(operand));
XmlDocument xml = new XmlDocument();
xml.Load("../../../xml/GetCapabilities.xml");
Communication.SendTcpXml(xml.InnerXml, new Uri("http://192.168.1.25/onvif/device_service"));
Tôi thực sự bối rối, bởi vì tôi không thể tìm thấy một sai lầm. Nó rất thú vị khi tôi sử dụng ngày, mật khẩu, nonce và tên người dùng từ chương trình quản lý thiết bị ONVIF (tôi đã lấy nó qua Wireshark), tôi thành công. NHƯNG Tôi không hiểu làm thế nào chương trình này băm mật khẩu, bởi vì tôi đang làm nó chính xác theo đặc điểm kỹ thuật và khi tôi sử dụng cùng một ngày, nonce và mật khẩu tôi không thể có được mật khẩu băm giống như chương trình này. Tôi sẽ biết ơn vì sự giúp đỡ nào, cảm ơn.
Tôi đã thực hiện một hàm Java nhỏ một thời gian trước đây để tính toán và hiển thị phần Tiêu đề (chỉ là một bài kiểm tra nhỏ). Tôi đã thử nghiệm kết quả bằng cách sử dụng SoapUI và máy ảnh Hikvision và hoạt động hoàn hảo; Tôi hy vọng nó sẽ giúp: http://pastebin.com/x16Prr2J – pparescasellas