Git Product home page Git Product logo

http2-keylog's Introduction

Debugging TLS using Go crypto/tls key log

With the crypto/tls KeyLogWriter we can dump TLS secrets in a format Wireshark can read to decrypt TLS sessions. This allows debugging on-the-wire data in applications, including perfect forward secrecy and without access to server private key.

The key log must be enabled in application being debugged, normally requiring a change in the source code. Both client and server can be modified to log the secrets.

The required tls.Config#KeyLogWriter feature will be in Go 1.8 release (expected to be released around January 31st, 2017). Until then, installing the development version ("go tip") is required.

Installation

Requirements: Go 1.8 or development version ("tip").

$ go get -u github.com/joneskoo/http2-keylog/h2keylog-server
$ go get -u github.com/joneskoo/http2-keylog/h2keylog-client

Capturing and decoding TLS client traffic

See h2keylog-client source code.

$ h2keylog-client https://http2.golang.org
Leaking TLS keys to ssl-keylog.txt
----------------------
HTTP/2.0 200 OK
Content-Length: 1593
Content-Type: text/html; charset=utf-8
Date: Wed, 16 Nov 2016 23:05:06 GMT

[body not shown]

You need to start a packet capture, e.g. with Wireshark, before you run h2keylog-client. h2keylog-client will write a text file that Wireshark can use to decrypt TLS traffic from the client.

ssl-keylog.txt:

# SSL/TLS secrets log file, generated by go
CLIENT_RANDOM b45c940d802822fd04c85a38b03b7227168457fbadb8be57a0f9cd05c4a0d2d3 6cbdd6f6bcdc5c3d7df7f0074b481eec649002ec64e2cfd91255e346aab617e72a1da2668176216e1d03f70505a335eb

You can now use the file as (Pre)-Master-Secret in SSL preferences in Wireshark to decode the traffic.

Wireshark showing decrypted TLS

Capturing and decoding TLS server traffic

See h2keylog-server source code.

$ h2keylog-server
Listening at https://:10443/
Leaking TLS keys to ssl-keylog.txt

Meanwhile in another terminal, and while Wireshark capture is active:

$ curl -k --http2 -6 'https://localhost:10443/'
This is an example server.

You can now use the file as (Pre)-Master-Secret in SSL preferences in Wireshark to decode the traffic.

Wireshark showing decrypted TLS

http2-keylog's People

Contributors

joneskoo avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.