cert is not yet valid: before=260517035651Z (1778990211), now=301081 #3622
|
Hello, trying to run an application using mongosse things are not working for me due to the way certificate timestamps are compared against the value returned by mg_millis CLOCK_MONOTIC, I guess. The output in question is this line: cert is not yet valid: before=260517035651Z (1778990211), now=301081 You can see that now is way off but the value shown in the message is the value returned by mg_now/mg_millis. If I change the corresponding lines in mg_millis to use CLOCK_REALTIME, things start working. Reading the various manual pages about clock_gettime, not a single one mentions that CLOCK_MONOTIC can be used to represent UTC dates. But that's what is assumed when comparing the certificate timestamps. I think CLOCK_MONOTONIC or CLOCK_MONOTONIC_RAW cannot be used to compare certificate dates with. 11f22288 4 mongoose.c:16076:mg_tls_hexd c x25519 sec: 46a62ce009c0483cab46bfb53e221a4f107788bce0b176cd274c8c86d7cfbf64 |
Replies: 4 comments 1 reply
|
The change in question seems to be this: #1615 Maybe mg_now() is/was supposed to return a UTC timestamp and stopped doing so due to mg_millis() no longer returning a UTC date after the change to CLOCK_MONOTONIC. |
|
Please see our documentation, and follow the guidelines in our tutorials. See our tests for example: Lines 5370 to 5378 in 9bc4d97 Lines 508 to 553 in 9bc4d97 |
|
Thanks. I noticed it myself. I was just confused and did not notice how time is implemented.
Setting a boot timestamp manually of course makes it work. Still wondering why it worked on Linux without that for years though. |
|
Application is deployed to Linux. It did not stop working there and it still is running there without any changes applied yet. Meanwhile I am questioning myself why it does work there at all. I compiled it on OpenBSD. It had issues with LibreSSL I could not figure out myself quickly so I switched to MG_TLS_BUILTIN there which then started displaying that debug message. I then tried to reproduce the LibreSSL issue on Linux again. Doing it that way: I can use MG_TLS_BUILTIN flawlessly on Linux, OpenBSD and Windows. I do get the same issue on Linux with OpenSSL as on OpenBSD with LibreSSL that way, though. Whereas doing it that way: no issues with OpenSSL on Linux and Windows. I go with MG_TLS_BUILTIN and be done with it. Thank you. |
mg_now()can't feed you wall clock if you don't tell it, Mongoose runs everywhere, and we don't know how you manage your timing.You just need to provide a suitable timebase
That can be SNTP or your OS, (even though you don't say, you are referring to something that seems to be Unix clock)
Please see our documentation, and follow the guidelines in our tutorials.
https://mongoose.ws/documentation/tutorials/udp/sntp-time-sync/
https://mongoose.ws/documentation/tutorials/tls/
See our tests for example:
mongoose/test/unit_test.c
Lines 5370 to 5378 in 9bc4d97