Go to file
Matthew Hughes d9cac6fbcd
Make Cert.not{before,after} timezone aware (#4805)
I noticed when running tests the output of
`web/src/js/__tests__/ducks/_tflow.ts` would change depending on how I
set my timezone, e.g.

    $ TZ=America/Los_Angeles pytest --quiet \
        test/mitmproxy/tools/web/test_app.py >/dev/null \
        && grep --extended-regexp 'not(after|before)' web/src/js/__tests__/ducks/_tflow.ts
                "notafter": 2235132207,
                "notbefore": 1604415807,
    $ TZ=Asia/Tokyo pytest --quiet \
        test/mitmproxy/tools/web/test_app.py >/dev/null \
        && grep --extended-regexp 'not(after|before)'  web/src/js/__tests__/ducks/_tflow.ts
                "notafter": 2235074607,
                "notbefore": 1604354607

It looks like this is because the `cert_to_json` function simply calls
`timestamp` the `datetime` object from
`x509.Certificate.not_valid_before`, however, this `datetime` object is
not timestamp aware, from the docs [1]:

> A naïve datetime representing the beginning of the validity period for
the certificate in UTC

So when serializing to JSON, first convert the `datetime` to UTC then
call `timestamp`.

A test was added by inspecting one of the test certs with:

    $ openssl x509 -in test/mitmproxy/net/data/text_cert_2 -text

Extracting the date and asserting on that.

The corresponding test has also been re-run so that `_tflow.ts` was
regenerated with it's correct value. Snapshots were also updated via:

    $(npm bin)/jest --updateSnapshot

[1] https://cryptography.io/en/latest/x509/reference/#cryptography.x509.Certificate.not_valid_after
2021-09-16 10:53:36 +02:00
.github Merge remote-tracking branch 'origin/main' into gsoc 2021-08-18 17:39:01 +02:00
docs socks5 upstream auth: use proxyauth option 2021-08-25 17:23:49 +02:00
examples Update examples/contrib/README.md 2021-08-22 14:57:20 +02:00
mitmproxy Make Cert.not{before,after} timezone aware (#4805) 2021-09-16 10:53:36 +02:00
release bump installbuilder (#4800) 2021-09-13 15:02:15 +00:00
test Make Cert.not{before,after} timezone aware (#4805) 2021-09-16 10:53:36 +02:00
web Make Cert.not{before,after} timezone aware (#4805) 2021-09-16 10:53:36 +02:00
.gitattributes test dumpfiles: .bin -> .mitm 2021-02-03 19:27:15 +01:00
.gitignore minor sans-io adjustments 2020-04-05 00:51:36 +02:00
CHANGELOG.md Merge pull request #4780 from mhils/socks5-auth 2021-08-27 10:30:54 +02:00
codecov.yml fix codecov report threshold (#4534) 2021-03-30 09:15:12 +00:00
CONTRIBUTING.md Improve Markdown syntax(styling) (#4496) 2021-03-11 19:13:02 +01:00
LICENSE GPLv3 -> MIT 2013-03-18 08:37:42 +13:00
MANIFEST.in remove pathod and pathoc 2020-12-13 20:21:11 +01:00
README.md master branch -> main branch 2021-03-30 15:30:45 +02:00
SECURITY.md Create SECURITY.md 2021-09-13 16:34:33 +02:00
setup.cfg docs++ 2021-02-13 00:13:37 +01:00
setup.py protobuf: accept older versions 2021-09-16 10:50:15 +02:00
tox.ini [requires.io] dependency update on main branch (#4801) 2021-09-13 15:25:35 +00:00

mitmproxy

Continuous Integration Status Coverage Status Latest Version Supported Python versions

mitmproxy is an interactive, SSL/TLS-capable intercepting proxy with a console interface for HTTP/1, HTTP/2, and WebSockets.

mitmdump is the command-line version of mitmproxy. Think tcpdump for HTTP.

mitmweb is a web-based interface for mitmproxy.

Installation

The installation instructions are here. If you want to install from source, see CONTRIBUTING.md.

Documentation & Help

General information, tutorials, and precompiled binaries can be found on the mitmproxy website.

mitmproxy.org

The documentation for mitmproxy is available on our website:

mitmproxy documentation stable mitmproxy documentation dev

If you have questions on how to use mitmproxy, please ask them on StackOverflow!

StackOverflow: mitmproxy

Contributing

As an open source project, mitmproxy welcomes contributions of all forms.

Dev Guide

Also, please feel free to join our developer Slack!

Slack Developer Chat