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

Add Keylog file with env variable SSLKEYLOGFILE (for openssl) #517

Closed
wants to merge 1 commit into from

Conversation

gcolin
Copy link

@gcolin gcolin commented Nov 4, 2024

Hello, this PR adds the generation of keylog file for debugging TLS with wireshark. This is working fine with openssl.

The env variable SSLKEYLOGFILE is used in others apps such as Curl, Firefox and Google Chrome.

Copy link
Member

@michalvasko michalvasko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, but to follow our code organization, a few changes will be required.

Starting with some minor issues, we generally use the nc_ prefix for all libnetconf2 functions (possible exception only for static ones) to set a "namespace" differentiating between all the used libraries. But, since this is OpenSSL-only, I think it can all be put into the session_openssl.c file without introducing additional ones. Ideally, there should be a TLS-specific init function (for example), which will not do anything for the mbedTLS but initializes this keylogger for OpenSSL to follow our TLS library wrappers.

src/keylog.c Outdated Show resolved Hide resolved
src/session_openssl.c Outdated Show resolved Hide resolved
@gcolin
Copy link
Author

gcolin commented Nov 6, 2024

Hello Michal, I updated the PR. the code is only in session_openssl.c

I added 2 global variable in file session_openssl.c: active_sessions and keylog_file_fp. maybe there is a better place to store these global variables.

Copy link
Collaborator

@Roytak Roytak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thank you for the contribution. Can you change the target branch to devel? Also would be great if you could run make format once you fix the small details I commented on. I think it will be good to merge then, if all tests pass.

src/session_openssl.c Outdated Show resolved Hide resolved
src/session_openssl.c Outdated Show resolved Hide resolved
src/session_openssl.c Outdated Show resolved Hide resolved
src/session_openssl.c Outdated Show resolved Hide resolved
src/session_openssl.c Outdated Show resolved Hide resolved
src/session_openssl.c Outdated Show resolved Hide resolved
@gcolin gcolin changed the base branch from master to devel November 6, 2024 21:26
@gcolin
Copy link
Author

gcolin commented Nov 6, 2024

There is a mutex to fix a concurrency issue in test_tls: the file was open twice.

I cannot change the "from" nokia:master. Should I recreate a new PR?

@michalvasko
Copy link
Member

No, the target branch is fine now.

@Roytak
Copy link
Collaborator

Roytak commented Nov 7, 2024

Is there a specific reason as to why the filename is passed as an env variable or that's just how curl handles it? I am thinking that setting it via an API may be better (and possibly doing this in netopeer2). Anyways, it will most likely be merged soon. I'll try to find out if this can be done with mbedtls as well, and possibly edit it accordingly.

@gcolin
Copy link
Author

gcolin commented Nov 7, 2024

Is there a specific reason as to why the filename is passed as an env variable or that's just how curl handles it? I am thinking that setting it via an API may be better (and possibly doing this in netopeer2). Anyways, it will most likely be merged soon. I'll try to find out if this can be done with mbedtls as well, and possibly edit it accordingly.

Hi, yes it is simpler:
. there is only one binary to update
. curl uses it. In our software, we use both curl and netopeer2
. other popular tools use this way

A colleague also suggested to have a paramater from netopeer2. For that, netopeer2 needs also an update.

That is cool to have the same in mbedtls.

Roytak pushed a commit to Roytak/libnetconf2 that referenced this pull request Nov 15, 2024
michalvasko pushed a commit that referenced this pull request Nov 15, 2024
@Roytak
Copy link
Collaborator

Roytak commented Nov 15, 2024

Hello, I decided to implement it since it required a bit more changes and I liked this enhancement. Sorry for not merging yours. Nonetheless, feel free to try it out and give us some feedback if need be. Thank you.

@Roytak Roytak closed this Nov 15, 2024
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

Successfully merging this pull request may close these issues.

3 participants