onvif icon indicating copy to clipboard operation
onvif copied to clipboard

Error: ONVIF SOAP Fault: Wsse authorized time check failed.

Open eharaj1 opened this issue 3 years ago • 8 comments

When I connect camera with Onvif (version 0.6.2) in nodejs then getting below error, Error: ONVIF SOAP Fault: Wsse authorized time check failed. at /node_modules/onvif/lib/utils.js:92:13 at Parser.<anonymous> (/node_modules/xml2js/lib/parser.js:304:18) at Parser.emit (events.js:314:20) at SAXParser.onclosetag (/node_modules/xml2js/lib/parser.js:262:26) at emit (/node_modules/sax/lib/sax.js:624:35) at emitNode (/node_modules/sax/lib/sax.js:629:5) at closeTag (/node_modules/sax/lib/sax.js:889:7) at SAXParser.write (/node_modules/sax/lib/sax.js:1436:13) at Parser.exports.Parser.Parser.parseString (/node_modules/xml2js/lib/parser.js:323:31) at Parser.parseString (/node_modules/xml2js/lib/parser.js:5:59)

Highly appreciate if someone help me, I am stuck from last few days and I did google also but didn't get any solution.

eharaj1 avatar Oct 10 '22 05:10 eharaj1

@eharaj1 Hi! I'm almost sure that the issue is in timestamp calculation here: https://github.com/agsh/onvif/blob/master/lib/cam.js#L966 For the security reasons system time on the ONVIF device must be the same as on the ONVIF client. For this we use timeShift property, which is set every time we connect to the device here: https://github.com/agsh/onvif/blob/master/lib/cam.js#L353 Next timeShift uses in timestamp calculation and then this value sends in the request header: https://github.com/agsh/onvif/blob/master/lib/cam.js#L999 Maybe you have some problems in calculation, maybe the systemDateAndTime of your device is wrong, or maybe device doesn't support Date ISO format (I've quickly found this question in google about format: https://stackoverflow.com/questions/49379790/error-while-using-authorization-in-soapui) So you can start your investigation from this point and look at the time you are sending, I suppose.

const cam = new Cam({
  hostname: <CAMERA_HOST>,
  username: <USERNAME>,
  password: <PASSWORD>
}, function(err) {
  console.log(cam.__envelopeHeader());
}

And don't forget to write here to write here what you got :smiley:

agsh avatar Oct 10 '22 07:10 agsh

@eharaj1 did you ever find a solution for this? I'm facing this as well.

john-harding avatar Jul 01 '23 00:07 john-harding

Also having this problem here:

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing"><s:Header><Security s:mustUnderstand="1" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><UsernameToken><Username>********</Username><Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">U0NuIDIt9A/sIJqVNHAzDTihhSw=</Password><Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">62rBhce3TXwF4bJ7NzKbHA==</Nonce><Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2023-10-16T00:18:29.079Z</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> Connection Failed for **************** Port: 80 Username: ******* Password: *********** Error: ONVIF SOAP Fault: Wsse authorized time check failed. at /home/ng/test/node_modules/onvif/lib/utils.js:101:13 at Parser. (/home/ng/test/node_modules/xml2js/lib/parser.js:308:18) at Parser.emit (events.js:314:20) at SAXParser.onclosetag (/home/ng/test/node_modules/xml2js/lib/parser.js:266:26) at emit (/home/ng/test/node_modules/sax/lib/sax.js:625:35) at emitNode (/home/ng/test/node_modules/sax/lib/sax.js:630:5) at closeTag (/home/ng/test/node_modules/sax/lib/sax.js:890:7) at SAXParser.write (/home/ng/test/node_modules/sax/lib/sax.js:1437:13) at Parser.exports.Parser.Parser.parseString (/home/ng/test/node_modules/xml2js/lib/parser.js:327:31) at Parser.parseString (/home/ng/test/node_modules/xml2js/lib/parser.js:5:59)

MrMEEE avatar Oct 15 '23 23:10 MrMEEE

Also having this problem here:

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing"><s:Header>********U0NuIDIt9A/sIJqVNHAzDTihhSw=62rBhce3TXwF4bJ7NzKbHA==2023-10-16T00:18:29.079Z</s:Header><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> Connection Failed for **************** Port: 80 Username: ******* Password: *********** Error: ONVIF SOAP Fault: Wsse authorized time check failed. at /home/ng/test/node_modules/onvif/lib/utils.js:101:13 at Parser. (/home/ng/test/node_modules/xml2js/lib/parser.js:308:18) at Parser.emit (events.js:314:20) at SAXParser.onclosetag (/home/ng/test/node_modules/xml2js/lib/parser.js:266:26) at emit (/home/ng/test/node_modules/sax/lib/sax.js:625:35) at emitNode (/home/ng/test/node_modules/sax/lib/sax.js:630:5) at closeTag (/home/ng/test/node_modules/sax/lib/sax.js:890:7) at SAXParser.write (/home/ng/test/node_modules/sax/lib/sax.js:1437:13) at Parser.exports.Parser.Parser.parseString (/home/ng/test/node_modules/xml2js/lib/parser.js:327:31) at Parser.parseString (/home/ng/test/node_modules/xml2js/lib/parser.js:5:59)

If I recall correctly this was fixed when I actually followed the full directions for installing the camera. In my case it was a Dahua camera, and I had to do the following:

  1. on my laptop install Dahua ConfigTool
  2. follow directions for changing the IP address of the camera with the ConfigTool

Then it worked

john-harding avatar Oct 15 '23 23:10 john-harding

Hi @john-harding

This was already working, and have stopped working..

I have doublechecked time settings on both the machine and the camera..

Any ideas?

MrMEEE avatar Oct 16 '23 21:10 MrMEEE

I'm also having this issue with a Dahau camera.

Perhaps this "UsernameToken with Timestamp token" section of Zeep doc might explain the issue? https://docs.python-zeep.org/en/master/wsse.html

I am connecting to my camera over WiFi on a LAN that does not have internet access. It seems perhaps for this code to work, I might need internet access so the code can access Internet documents? Would hope to download those documents to local machine to not need this if possible.

NorthernNoober avatar Jan 02 '24 21:01 NorthernNoober

Can you give me remote access to the camera? Then I will have a quick look. I have all sorts of makes of IP camera here, but no Dahua cameras. I would need access to Port 80 (for ONVIF commands). Don't need the RTSP video stream.

Thanks, Roger

RogerHardiman avatar Jan 03 '24 06:01 RogerHardiman

For me, I figured out that the error is actually correct, as DST on the Dahua cameras (at least the ones I have) is defective..

If I disable DST, it works fine..

MrMEEE avatar Jan 03 '24 23:01 MrMEEE