This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Get Snapshot from Hikvision Camera
#15
Thanks, here's a couple of things you can try:

1. Remove space between items in the Authorization header.
Replace:
Code:
return 'Digest ' .. table.concat(digest, ', ')
With:
Code:
return 'Digest ' .. table.concat(digest, ',')

2. Modify the items and their order in the header.
Replace:
Code:
local auth = {
  { 'username', user },
  { 'realm', ht.realm },
  { 'nonce', ht.nonce },
  { 'uri', uri },
  { 'cnonce', cnonce },
  { 'nc', nc, unquote = true },
  { 'qop', 'auth' },
  { 'algorithm', 'MD5' },
  { 'response', response },
}
With:
Code:
local auth = {
  { 'username', user },
  { 'realm', ht.realm },
  { 'nonce', ht.nonce },
  { 'uri', uri },
  { 'cnonce', cnonce },
  { 'nc', nc, unquote = true },
  -- { 'algorithm', 'MD5' },
  { 'response', response },
  { 'qop', 'auth' },
}

3. Make the cnonce longer.
Replace:
Code:
local cnonce = string.format('%08x', os.time())
With:
Code:
local cnonce = md5sum(string.format('%08x', os.time()))

When setting cnonce manually I get the same header as curl does by applying change 1 and 2.
Reply


Messages In This Thread
RE: Get Snapshot from Hikvision Camera - by admin - 15.03.2023, 10:55

Forum Jump: