Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NetBox/WebDav sometimes rejects valid SSL certificates #390

Open
alabuzhev opened this issue Feb 22, 2024 · 0 comments
Open

NetBox/WebDav sometimes rejects valid SSL certificates #390

alabuzhev opened this issue Feb 22, 2024 · 0 comments

Comments

@alabuzhev
Copy link
Contributor

FarGroup#34 by @ArkBrj

NetBox/WebDav sometimes treats valid certificates as invalid due to what seems to be some rounding error in datetime conversions.
Example of a valid certificate rejected by NetBox: myfiles.fastmail.com
According to https://www.ssllabs.com, at the time of writing the certificate is valid until Thu, 02 Nov 2023 23:59:59.
The issue seems to be related to the fact that the certificate expires one second before the midnight.

I briefly debugged the issue and discovered that DateTimeToTimeStamp returns invalid Result.Time (86400000) when it converts this timestamp. This value is incorrect because it is exactly the number of milliseconds in a day so the valid range of values in this field is 0-86399999. Later on this incorrect value causes error in some other function (forgot to write down which one).

Below are few details.

TWebDAVFileSystem::DoNeonServerSSLCallback gets the certificate valid till 02 Nov 2023 23:59:59.
ValidUntil = 1698998399

It converts it to TDateTime format:
Data.ValidUntil.FValue = 45232.99998842592322

Sysutils::DateTimeToTimeStamp gets called for this value. It calculates fractpart as:
fractpart = 0.99998842592322034761

Later on Result.Time gets calculated as ToInt(fractpart * MSecsPerDay + 0.5):
Result.Time = 86400000

Relevant callstack:
00 0000003c8eafc370 00007ffd7ccc22d9 NetBox!Sysutils::DateTimeToTimeStamp+0x41 [D:\a\Far-NetBox\Far-NetBox\src\base\Sysutils.cpp @ 499]
01 0000003c8eafc3a0 00007ffd7ccc229f NetBox!Sysutils::DecodeDateFully+0x2d [D:\a\Far-NetBox\Far-NetBox\src\base\Sysutils.cpp @ 1269]
02 0000003c8eafc3f0 00007ffd7ccdf542 NetBox!Sysutils::DecodeDate+0x13 [D:\a\Far-NetBox\Far-NetBox\src\base\Sysutils.cpp @ 1328]
03 0000003c8eafc440 00007ffd7cd32354 NetBox!Sysutils::FormatDateTime+0x4a [D:\a\Far-NetBox\Far-NetBox\src\base\Sysutils.cpp @ 1452]
04 0000003c8eafc530 00007ffd7cccf4e3 NetBox!TWebDAVFileSystem::VerifyCertificate+0x2cc [D:\a\Far-NetBox\Far-NetBox\src\core\WebDAVFileSystem.cpp @ 2536]
05 0000003c8eafc6e0 00007ffd7ceaecd3 NetBox!TWebDAVFileSystem::DoNeonServerSSLCallback+0x1fb [D:\a\Far-NetBox\Far-NetBox\src\core\WebDAVFileSystem.cpp @ 2651]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant