-
Notifications
You must be signed in to change notification settings - Fork 89
Add key logging for TLS 1.3 and TLS 1.2 (#523) #542
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
base: master
Are you sure you want to change the base?
Conversation
|
(as the CI verifies that tests can be executed after every commit, you will have to squash/fixup the commits together) |
a964b2b to
67bd0c8
Compare
|
@tomato42 considering how people may use this library, this may not be process or thread safe. I'm thinking about changing this to use logger class that can be passed to the TLSConnection's init which can handle IO in a safer way. Also taking into consideration your comments |
yes, we can have two |
@tomato42 supporting all common OSes like Linux, macOS, and Windows? Fortunately, for posix it should be the same using |
sigh yeah, we probably should just give up and simply open the file in append mode, dump our stuff as quickly as possible, and close it; then document that it is not thread-safe and intended for debugging only... 😔 |
I have it working for POSIX using |
yes, let's do that; I don't have a windows machine to test it on either |
67bd0c8 to
03450b9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 3 files at r1, 3 of 3 files at r2, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @nickrabbott)
-- commits line 2 at r2:
"WIP"?
tlslite/tlsconnection.py line 90 at r2 (raw file):
:param logging_enabled: Enable logging session secrets to the SSLKEYLOGFILE env variable. :type logging_enabled: bool
Why have it controlled by two settings at once?
presence of environment variable should be enough; with the ability to override it by setting the name of the file to log to, not if the logging should work
tlslite/session.py line 102 at r2 (raw file):
self.ec_point_format = 0 self.cl_handshake_traffic_secret = None self.sr_handshake_traffic_secret = None
they are not read anywhere?
tlslite/sslkeylogging.py line 26 at r2 (raw file):
class SSLKeyLogger: """ Write session secrets to the SSLKEYLOGFILE environment variable. Implemented to be thread-safe at the class
"...to the file pointed to by SSLKEYLOGFILE..."
tlslite/sslkeylogging.py line 50 at r2 (raw file):
return if isinstance(keys, tuple):
I don't like this... there's no functional difference between passing the values to log in tuples vs lists...
honestly I think a cleaner check would be for length of the iterable being 3 and first element being str...
03450b9 to
25da541
Compare
yeah I wasn't ready to say it was done yet and still had some tests I wanted to add. "WIP" has been removed
The thought here was to have a way to opt-out of the logging, but as you say the presence of the env variable should be enough. That change is in effect
self.ec_point_format = 0
self.cl_handshake_traffic_secret = None
self.sr_handshake_traffic_secret = NoneI added these to the session instance so I could assert their values in the log when the tests used real sockets. They're in use now that I have a test using
The reason I made this method accept both a tuple and a list of tuples is because 1.2 only has one to log, but 1.3 has many. I understand not liking that, so it's probably best to just have the caller provide a list of tuples, even if the list only contains one (in the case of 1.2). That makes a check not necessary since the purpose of the check was whether the type was a tuple or list |
5ece312 to
c2295fd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 4 files at r3, 3 of 3 files at r4, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @nickrabbott)
tlslite/sslkeylogging.py line 49 at r4 (raw file):
self.lock_write = unsafe_write def log_session_keys(self, keys):
doc string missing
c2295fd to
8a64a1a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r5, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @nickrabbott)
|
@nickrabbott looks like there is still some code missing, could you take a look at the test failures? |
|
@tomato42 I see, it's an issue with the SRP fault tests. In these tests the handshake intentionally aborts, so I have one question before pushing the fix. After the tests passed locally, I'm seeing issues with the pylint and diff-quality stage of the pipeline. It could just be an issue with my local environment... Are those steps expected to pass locally before pushing, or are they primarily intended in CI? |
those are guidelines that you might have insufficient test coverage for the changes, they are not blocking for the PR |
SSLKEYLOGFILE implementation and tests
8a64a1a to
bdc72fc
Compare
|
|
||
| # dbm module may create files with different names depending on | ||
| # platform | ||
| candidates = [db_name, db_name + ".dat", db_name + ".db"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm on a mac and ".db" was the file extension
|
@tomato42 I saw you approved, but when I pushed the fix for the test that dismissed the approval. Is there anything else needed? |
SSLKEYLOGFILE support
fixes #523
This change is