agsh / onvif

ONVIF node.js implementation
http://agsh.github.io/onvif/
MIT License
681 stars 231 forks source link

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

Open eharaj1 opened 1 year ago

eharaj1 commented 1 year ago

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.

agsh commented 1 year ago

@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:

john-harding commented 1 year ago

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

MrMEEE commented 9 months ago

Also having this problem here:

****U0NuIDIt9A/sIJqVNHAzDTihhSw=62rBhce3TXwF4bJ7NzKbHA==2023-10-16T00:18:29.079Z</s:Header> 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)

john-harding commented 9 months ago

Also having this problem here:

](http://www.w3.org/2005/08/addressing%22%3E)****U0NuIDIt9A/sIJqVNHAzDTihhSw=62rBhce3TXwF4bJ7NzKbHA==2023-10-16T00:18:29.079Z</s:Header>](http://www.w3.org/2001/XMLSchema%22%3E) 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

MrMEEE commented 9 months ago

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?

NorthernNoober commented 6 months ago

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.

RogerHardiman commented 6 months ago

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

MrMEEE commented 6 months ago

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..