Skip to content

shrimple πŸ‡΅πŸ‡± πŸ³οΈβ€βš§οΈ

shrimple mind. shrimple problems. complex solutions. she/her

Getting TLS1.3 Key Log from Go application with requests by a library, and using it in Wireshark

Posted on February[²⁰26], Tuesday 03.February[²⁰26], Tuesday 03. By Shrimple 1 Comment on Getting TLS1.3 Key Log from Go application with requests by a library, and using it in Wireshark

Today I wanted to sniff on TLS traffic of hell, a “mastodon client” that seemed to not want to work with things that aren’t Mastodon. The network calls are mostly made from within a library, hellclient-go-mastodon fork of go-mastodon.

SSLKEYLOGFILE turned out to be a standard, now even RFC 9850, for TLS client instrumentation. But Go standard library doesn’t simply write the secrets to a log file in coupling with the obscure environment variable. Not much libraries seem to do it β€” just programs like major web browsers and curl. (Perhaps bizarrely, this Haskell package adds it coupled with an environment variable β€” introduced to one’s Haskell code by means of adding nothing more than an import statement.)

After a while I figured it out, with help from among others https://endorama.dev/2023/inspecting-tls-traffic-golang/ and https://stackoverflow.com/questions/72719194/extracting-tls-secrets-in-go.

Importing library from own sources

As the project used go.mod, I could clone the library alongside and add

replace codeberg.org/penny64/hellclient-go-mastodon => ../hellclient-go-mastodon

Setting the TLS config

Then in the library, I found mastodon.go using *http.DefaultClient (which is just &http.Client{},as I even saw someone complain) β€” as client put into a field in its own Client struct. In the function that created that struct, I just added (importing os and crypto/tls)

fi, _ := os.Create("/tmp/klw")
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{
        KeyLogWriter: fi,
}

β€” to create a key log file and add a TLSClientConfig to the variable http.DefaultTransport instance of struct http.Transport, which is used by default whenΒ Transport field in http.Client is nil.
There was therefore no need to replace it with a new &http.Client{ Transport: … }, and it had the potential to work in random additional places in the whole program.

But there was then also no need to bother with importing the library from own sources, since we’re just setting standard library global variable defaults. Putting those few lines on top of func main() body turned out to work just as fineimport "net/http". Run go build ., the resulting executable will appear in the directory.

Running Wireshark

Before you read the official wiki page, you may wander around the Wireshark GUI and find Tools β†’ TLS Keylog Launcher. That seems to be nothing more but a tool that:

  1. sets the TLS (Pre)-Master-Secret log file path (tls.keylog_file) setting
  2. lets you execute a command line with the SSLKEYLOGFILE environment variable set.

β€” and you still have to remember to start recording beforehand, and there is no additional benefits (think, some filtering) that come from using it. If you want to be able to interact with your TUI program, the Run button is not for you in this dialog. But you can set the filename setting there (remember to clickΒ Save), just as well as you can in Edit β†’ Preferences β†’ Protocol β†’ TLS settings as (Pre)-Master-Secret log filename.

Steps:
  1. Delete the file if it exists, because otherwise Wireshark doesn’t seem to detect its truncation.
  2. Start recording
  3. Run your application
  4. Use ip.addr == … filter if you know the IP, or tls and (http or http2 or http3) (I don’t include quic because I’m not sure if it even works and also it tends to clutter with results from browser activity)

If you want to isolate traffic from just your program because things are too messy to filter, you can probably experiment with running both the capture and the program in ip netns exec (see man 8 ip-netns).

0 Give it a Click if you enjoyed (it does not federate)
Programming Technologies Tags:golang, linux, network, programming-tips

Post navigation

Previous Post: Distributed file version management in 15 minutes of Bash
Next Post: Simplistic reconciliation of mostly-append text files like Offpunk lists: draft involving Kahn’s algorithm

Related Posts

  • Create Block Theme with Block Editor in WordPress Playground β€” a first Programming Technologies
  • Check up on RSS/Atom dates in dozen+ lines of Bash Programming Technologies
  • Implementing proper natural language grep β€” approach Programming Technologies
  • Replace `chardet` Python library immediately Influencing Society
  • Trying to run WordPress Studio, failing Programming Technologies

Comment (1) on “Getting TLS1.3 Key Log from Go application with requests by a library, and using it in Wireshark”

  1. Penny says:
    April[²⁰26], Thursday 30. at 5am

    @shrimple Were you able to fix hell? Id love to patch it

    Reply as
    Reply on the Fediverse

    Remote Reply

    Original Comment URL

    Paste the comment URL into the search field of your favorite open social app or platform.

    Your Profile

    Or, if you know your own profile, we can start things that way!
    Why do I need to enter my profile?

    This site is part of the ⁂ open social web, a network of interconnected social platforms (like Mastodon, Pixelfed, Friendica, and others). Unlike centralized social media, your account lives on a platform of your choice, and you can interact with people across different platforms.

    By entering your profile, we can send you to your account where you can complete this action.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Atom feed for this page

Atom feed for this blog

against-messy-software akkoma Atom|RSS_feeds bash big.ugly.git.patch. chromium-and-derivatives community fragment golang kde language-models-ai links2 linux me microsoft-edge network offpunk offpunk:lists offpunk:redirections oss-contributing perl programming-tips scripting smolweb subscribe superuser window-decorations wordpress-diving Wordpress_ActivityPub_plugin

Categories

  • Guides to Free Open Source

    (1)
  • Influencing Society

    (4)
  • Meta

    (4)
  • Oddities of alternate reality

    (1)
  • Programming Technologies

    (6)
  • Rookie Repairs

    (1)
  • Smol Web Habits

    (5)
  • Software Imposed On Us

    (1)
  • Wild Software Writing

    (8)
  • March 2026 (13)
  • February 2026 (5)
  • January 2026 (10)
Fediverse reactions

Post URL

Paste the post URL into the search field of your favorite open social app or platform.

Your Profile

Or, if you know your own profile, we can start things that way!
Why do I need to enter my profile?

This site is part of the ⁂ open social web, a network of interconnected social platforms (like Mastodon, Pixelfed, Friendica, and others). Unlike centralized social media, your account lives on a platform of your choice, and you can interact with people across different platforms.

By entering your profile, we can send you to your account where you can complete this action.

shrimple πŸ‡΅πŸ‡±  πŸ³οΈβ€βš§οΈ
shrimple πŸ‡΅πŸ‡± πŸ³οΈβ€βš§οΈ
@shrimple@www.shrimple.pl
Follow

shrimple mind. shrimple problems. complex solutions. she/her

28 posts
12 followers

Follow shrimple πŸ‡΅πŸ‡± πŸ³οΈβ€βš§οΈ

My Profile

Paste my profile into the search field of your favorite open social app or platform.

Your Profile

Or, if you know your own profile, we can start things that way!
Why do I need to enter my profile?

This site is part of the ⁂ open social web, a network of interconnected social platforms (like Mastodon, Pixelfed, Friendica, and others). Unlike centralized social media, your account lives on a platform of your choice, and you can interact with people across different platforms.

By entering your profile, we can send you to your account where you can complete this action.

  • Why follow requests here and can I even be followed Meta
  • Distributed file version management in 15 minutes of Bash Wild Software Writing
  • How I ran a dev localhost Akkoma instance (commands listing!) on openSUSE, fixed a bug, investigated terminal emulator Guides to Free Open Source
  • On OVH hosting, you can’t opt out from protection Meta
  • Create Block Theme with Block Editor in WordPress Playground β€” a first Programming Technologies
  • A few links to Mozilla Sidebar panels directories Smol Web Habits
  • My setup is a distraction β€” netbook case Smol Web Habits
  • Links 2, a graphical browser I wanna build upon. And a quick look at how ELinks is doing. Wild Software Writing

shrimple@shrimple.pl

Copyright © 2026 shrimple πŸ‡΅πŸ‡± πŸ³οΈβ€βš§οΈ.

Powered by PressBook News WordPress theme