svaldez | 72b40a3 | 2016-04-26 16:54:38 | [diff] [blame] | 1 | # Debugging SSL on Linux |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 2 | |
| 3 | To help anyone looking at the SSL code, here are a few tips I've found handy. |
| 4 | |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 5 | [TOC] |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 6 | |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 7 | ## Logging |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 8 | |
| 9 | There are several flavors of logging you can turn on. |
| 10 | |
svaldez | 72b40a3 | 2016-04-26 16:54:38 | [diff] [blame] | 11 | * `SSLClientSocketImpl` can log its state transitions and function calls |
| 12 | using `base/logging.cc`. To enable this, edit |
| 13 | `net/socket/ssl_client_socket_impl.cc` and change `#if 1` to `#if 0`. See |
| 14 | `base/logging.cc` for where the output goes (on Linux, usually stderr). |
| 15 | |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 16 | * `HttpNetworkTransaction` and friends can log its state transitions using |
| 17 | `base/trace_event.cc`. To enable this, arrange for your app to call |
| 18 | `base::TraceLog::StartTracing()`. The output goes to a file named |
| 19 | `trace...pid.log` in the same directory as the executable (e.g. |
| 20 | `Hammer/trace_15323.log`). |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 21 | |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 22 | ## Network Traces |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 23 | |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 24 | http://wiki.wireshark.org/SSL describes how to decode SSL traffic. Chromium SSL |
| 25 | unit tests that use `net/base/ssl_test_util.cc` to set up their servers always |
| 26 | use port 9443 with `net/data/ssl/certificates/ok_cert.pem`, and port 9666 with |
| 27 | `net/data/ssl/certificates/expired_cert.pem` This makes it easy to configure |
| 28 | Wireshark to decode the traffic: do |
| 29 | |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 30 | Edit / Preferences / Protocols / SSL, and in the "RSA Keys List" box, enter |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 31 | |
| 32 | 127.0.0.1,9443,http,<path to ok_cert.pem>;127.0.0.1,9666,http,<path to expired_cert.pem> |
| 33 | |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 34 | e.g. |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 35 | |
| 36 | 127.0.0.1,9443,http,/home/dank/chromium/src/net/data/ssl/certificates/ok_cert.pem;127.0.0.1,9666,http,/home/dank/chromium/src/net/data/ssl/certificates/expired_cert.pem |
| 37 | |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 38 | Then capture all tcp traffic on interface lo, and run your test. |