Commit Graph

284 Commits

Author SHA1 Message Date
Maximilian Hils 832e735b0a
Fix clipboard handling in safari (#6917)
* fix clipboard handling in safari

closes #6911, #6909

Co-authored-by: Can Yesilyurt <36952967+canyesilyurt@users.noreply.github.com>

* [autofix.ci] apply automated fixes

* update dependencies

---------

Co-authored-by: Can Yesilyurt <36952967+canyesilyurt@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-06-12 14:59:40 +02:00
Maximilian Hils 460789b7be
Autofix generated JS files and do not patch them in tests (#6910)
* autofix generated JS files and do not patch them in tests

* autofix: setup python

* [autofix.ci] apply automated fixes

* autofix: setup node

* add missing newline

* fixup

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-06-12 01:25:46 +02:00
Maximilian Hils 968a169077
Update CHANGELOG.md 2024-06-11 15:02:28 +02:00
Gaurav Jain fa8b8998d7
Update strip_ech addon to use the new DNS HTTPS records API (#6905)
* Update and rename strip_ech addon to use new DNS HTTPS records API

* Update CHANGELOG.md

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-06-09 20:26:26 +00:00
Gaurav Jain 03c8db88bb
Allow parsing of HTTPS record from DNS RDATA (#6884)
* Unpack HTTPS DNS record data

* Fix linting issues

* Add entry to CHANGELOG.md

* [autofix.ci] apply automated fixes

* Reorder functions

* [autofix.ci] apply automated fixes

* Rename private methods

* Use Enum to store constants

* Restructure constants

* Handle errors

* Use dataclasses to represent HTTPS records

* [autofix.ci] apply automated fixes

* Fix mypy errors

* [autofix.ci] apply automated fixes

* Allow packing of HTTPSRecords to its byte format

* Add tests for https_record

* [autofix.ci] apply automated fixes

* Rename https_record to https_records

* [autofix.ci] apply automated fixes

* Increase test coverage

* [autofix.ci] apply automated fixes

* Increase test coverage

* [autofix.ci] apply automated fixes

* Increase test coverage

* [autofix.ci] apply automated fixes

* Add comments

* Restructure HTTPS record API

* [autofix.ci] apply automated fixes

* Remove  from public API

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-06-09 19:56:21 +00:00
Gaurav Jain de871df53b
Add blockech addon (#6876)
* Add blockech addon

* Update CHANGELOG.md

* [autofix.ci] apply automated fixes

* Add tests

* [autofix.ci] apply automated fixes

* Fix tests

* Add suggested changes

* [autofix.ci] apply automated fixes

* rephrase changelog to be more user-centric

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Maximilian Hils <git@maximilianhils.com>
2024-05-28 18:10:46 +02:00
Orhan Kavrakoğlu 8cf0cca702
Fix slowdown when sending large data over HTTP/2 (#6873) (#6875)
* Do not mutate data when splitting into chunks (#6873)

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-05-25 16:13:17 +02:00
Maximilian Hils 215dfea515
Skip proxyauth on client replay, fix #6836 (#6866)
* skip proxyauth on client replay, fix #6836

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-05-22 00:31:48 +00:00
Alexander Prinzhorn 14d5fa0474
Update PyInstaller spec to set the u (unbuffered) flag (#6821)
* Update PyInstaller spec to set the u (unbuffered) flag
* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-04-28 10:25:51 +02:00
Maximilian Hils b5574fb298
Fix program exit when `n` is passed (#6819)
* fix program exit when `n` is passed

fix #6818

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-04-24 14:14:54 +02:00
Maximilian Hils 2c96c96e75
prefix version tags with 'v' (#6810) 2024-04-19 21:28:05 +02:00
mitmproxy release bot 8ab74b4f0f mitmproxy 10.3.0 2024-04-17 11:31:13 +00:00
Maximilian Hils f997cd3a21
add `server_connect_error` hook (#6806)
* Add server connection error hook

* Add new hook to api-events doc

* Rename and add test

* Forgot to commit

* Small fix

* [autofix.ci] apply automated fixes

* fixed test_server.py

* fixed 'Import block is un-sorted or un-formatted'

* [autofix.ci] apply automated fixes

* test++, doc++

* add CHANGELOG entry

* [autofix.ci] apply automated fixes

* fix authors

* fix test

* [autofix.ci] apply automated fixes

---------

Co-authored-by: haanhvu <haanh6594@gmail.com>
Co-authored-by: spacewasp <spacewasp1982@gmail.com>
2024-04-17 12:47:06 +02:00
Maximilian Hils bfbd777cbb
Fix certs for unicode domains (#6796)
* fix certs for unicode domains

fix #6729

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-04-12 17:22:19 +02:00
Maximilian Hils 00d6c88af5 docs: fix #6750 2024-04-12 15:55:45 +02:00
Maximilian Hils 11a086805c
fix cryptography DeprecationWarning (#6790)
* fix cryptography DeprecationWarning

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-04-09 10:14:52 +02:00
txrp0x9 1b44691d33
Fix saving of websocket flows (#6767)
* fix websocket message saving

* [autofix.ci] apply automated fixes

* added websocket as a supported format to export command, with tests for the same

* [autofix.ci] apply automated fixes

* added websocket message serialization in raw export, with test coverage

* [autofix.ci] apply automated fixes

* code suggestion fixes

Co-authored-by: Maximilian Hils <github@maximilianhils.com>

* [autofix.ci] apply automated fixes

* suggestion fixes

* fix merged code

* added tests for websocket export and cut.save

* [autofix.ci] apply automated fixes

* fix tests and add changes to changelog

* fix tests and add changes to changelog

* fix changelog

* fix changelog

* changelog addition

* changelog revert

* test fix

* [autofix.ci] apply automated fixes

* more test coverage

* [autofix.ci] apply automated fixes

* add changes to changelog

* add more test coverage

* [autofix.ci] apply automated fixes

* simplify

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Maximilian Hils <github@maximilianhils.com>
2024-04-04 19:07:20 +00:00
Changsin 8cf0cba1cb
Setting SIG_IGN for SIGPIPE errors (#6764)
* Setting SIG_IGN for SIGPIPE errors

    The issue was reported in https://github.com/mitmproxy/mitmproxy/issues/6744

    Problem description:
    When there is a sudden surge of requests, mitmproxy will hit SIGPIPE (broken pipe) errors because it was trying to write to a closed socket. The stacktrace is:
    File "asyncio/runners.py", line 44, in run
    File "asyncio/base_events.py", line 636, in run_until_complete
    File "asyncio/base_events.py", line 603, in run_forever
    File "asyncio/base_events.py", line 1909, in _run_once
    File "asyncio/events.py", line 80, in _run
    File "mitmproxy/proxy/server.py", line 294, in handle_connection
    File "mitmproxy/proxy/server.py", line 407, in server_event
    File "asyncio/streams.py", line 325, in write
    File "asyncio/selector_events.py", line 924, in write

    When this happens, the process terminates unless handled
    The fix will allow the process to continue to run.

* add changelog entry

* [autofix.ci] apply automated fixes

* Handling SIGPIPE only in non-Windows platforms

* [autofix.ci] apply automated fixes

* nit: make check platform-agnostic

---------

Co-authored-by: changsin <changsin@strac.io>
Co-authored-by: Maximilian Hils <github@maximilianhils.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-04-03 14:17:56 +00:00
winy ccf45a92e4
Add hex editor for non text files (#6768)
* add hex editor for non text files

* update changelog

* [autofix.ci] apply automated fixes

* fix failing text

* fix tests

* fix lint

* [autofix.ci] apply automated fixes

* Update test/mitmproxy/tools/console/test_master.py

Co-authored-by: Maximilian Hils <github@maximilianhils.com>

* Update test/mitmproxy/tools/console/test_master.py

Co-authored-by: Maximilian Hils <github@maximilianhils.com>

* a few changes

* fix tests

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Maximilian Hils <github@maximilianhils.com>
2024-04-02 13:19:01 +02:00
Gaurav Jain 16a28bcd1f
Add primitive websocket interception and modification (#6766)
* Add primitive websocket interception and modification

* Update CHANGELOG.md

* Fix UI tab renaming on interception

* [autofix.ci] apply automated fixes

* Improve code readability

* [autofix.ci] apply automated fixes

* Improve code readability

* [autofix.ci] apply automated fixes

* Improve code readability

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-04-02 00:46:30 +02:00
Matteo Luppi e834259215
Feature/button-to-close-flow-details-view (#6734)
* button to close flow details section + test

* [autofix.ci] apply automated fixes

* update changelog

* remove useless imports

* change span to button

* update snapshots

* move the close button to the left

* change color to gray

* add icon instead of text

* update tests

* review changes

* remove useless stuff

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-03-25 20:07:46 +01:00
Maximilian Hils d4200a7c0d
Fix async `client_connected` handlers crashing mitmproxy (#6749)
* ensure that `Start` is always the first event

fix #6745

* simplify proxy handler

this commit should not do any functional changes

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-03-20 22:13:28 +00:00
Maximilian Hils ce0827c7a5
fixup CHANGELOG.md 2024-03-20 23:10:04 +01:00
Jeremy Lainé 0d68e193b1
Update aioquic dependency to >= 1.0.0, < 2.0.0 (fixes: #6746) (#6747)
#### Description

This fixes some specification compliance issues as well as a potential
DoS vulnerability.

Start with version 1.0.0, aioquic follows semantic versioning, so no
breaking changes will occur before version 2.0.0.

#### Checklist

 - [x] I have updated tests where applicable.
 - [x] I have added an entry to the CHANGELOG.
2024-03-20 21:31:03 +01:00
jaywor1 a26013908a
enable stdin reading for mitmweb (#6732)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Maximilian Hils <github@maximilianhils.com>
2024-03-11 21:41:44 +00:00
Matteo Luppi f0dea82e8b
web: add comments (#6709)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-03-11 15:55:19 +01:00
Alessandro Surace 1a489f6a8c
docs: how to create the proper CA (#5370)
Co-authored-by: Maximilian Hils <git@maximilianhils.com>
2024-03-11 10:10:06 +00:00
Daniel López Guimaraes ee5aac0a12
Fix Multipart content view parsing (#6653)
#### Description

On get_message_content_view, the content type wasn't including the
boundary, and was only setting the MIME type. This made the multipart
content view unusable, as the boundary was required on parsing. To fix
the issue, we assign the full content type instead.

This wasn't triggered by any previous tests because they would test
against the multipart parser directly, and not the generic parser.

#### Checklist

 - [X] I have updated tests where applicable.
 - [x] I have added an entry to the CHANGELOG.

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-03-08 22:33:02 +01:00
mitmproxy release bot 13f42105fd mitmproxy 10.2.4 2024-03-07 20:55:22 +00:00
Maximilian Hils 0f7f0d0534
fix display of error messages on early shutdown (#6719)
fix #6707
fix #6716
2024-03-07 20:41:26 +00:00
Maximilian Hils 9acf06427a
Use `_utc` APIs from cryptography, fix #6717 (#6718) 2024-03-07 17:00:51 +01:00
mitmproxy release bot 49c9074b46 mitmproxy 10.2.3 2024-03-06 20:58:54 +00:00
Matteo Luppi a128672ec7
Fix Bug view options menu (#6697)
#### Description

This PR fixes bug described here : #4448 

I set a max-height property and a scroll in case of overflow on the
y-axis.

#### Checklist

 - [x] I have updated tests where applicable.
 - [x] I have added an entry to the CHANGELOG.

---------

Co-authored-by: Maximilian Hils <git@maximilianhils.com>
2024-03-06 21:55:26 +01:00
Denis Stanishevsky 766b5451b7
Allow --allow-hosts and --ignore-hosts to work together (#6711)
#### Description

The mutual exclusivity of the allow-hosts and ignore-hosts parameters
looks like an unnecessary obstacle and does not make much sense.

It is very convenient to use a proxy only for the domain of your
service, but at the same time ignore some subdomains, especially when
they serve some kind of CDNs with a large amount of data.

Although this filtering could be implemented using regexp with negative
lookahead, but it complicates configuration and is not as clear as
conjuction of allow and deny filters.

#### Checklist

 - [x] I have updated tests where applicable.
 - [x] I have added an entry to the CHANGELOG.

---------

Co-authored-by: Denis Stanishevskiy <>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-03-06 21:29:08 +01:00
Gaurav Jain b63a600f84
Allow runtime modifications of HTTP flow filters for server replays (#6695)
#### Description
Fixes #4506
`mitmproxy` during server-replay mode, calculates the hashes of flows
from input files based on user defined filters and uses them to compare
against hashes of incoming requests to serve the corresponding stored
response by matching the hash. However, during runtime, if the user
changes any of the filters, `mitmproxy` fails to recalculate the hashes
of input flows and hence doesn't return the intended response. This PR
fixes this issue by recomputing the hashes for every flow whenever a
filter(option) used for computing hashes is changed.

#### Checklist

 - [x] I have updated tests where applicable.
 - [x] I have added an entry to the CHANGELOG.

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Maximilian Hils <git@maximilianhils.com>
2024-02-28 18:57:06 +00:00
Gaurav Jain 92c556afbe
Add `content_view_lines_cutoff` option to mitmdump (#6692)
#### Description

Fixes #4476 
This PR adds the already existing `content_view_lines_cutoff` option to
`mitmdump` to filter the number of content lines shown when
`flow_detail` option is set to `3`. By default this option's value is
set to `512`

Updated tests that check for `cutoff` in responses that cross `512`
lines(with the default value set)
Added tests to ensure that custom values for `content_view_lines_cutoff`
works as intended

#### Verification
1. run `mitmdump --set flow_detail=3 --set content_view_lines_cutoff=3`
2. run `curl --proxy http:/127.0.0.1:8080 "https://google.com/"`

#### Before
<details>
<summary>Output</summary>

```
[15:00:41.441] HTTP(S) proxy listening at *:8080.
[15:00:53.236][127.0.0.1:38826] client connect
[15:00:53.520][127.0.0.1:38826] server connect google.com:443 (142.250.183.238:443)
127.0.0.1:38826: GET https://google.com/ HTTP/2.0
    user-agent: curl/8.5.0
    accept: */*

 << HTTP/2.0 301 Moved Permanently 220b
    location: https://www.google.com/
    content-type: text/html; charset=UTF-8
    content-security-policy-report-only: object-src 'none';base-uri 'self';script-src 'nonce-7rNdfc7B14cr_4JZskk3AQ' 'strict-dynamic' 'report-sample' 'unsafe-eval' 'unsafe-inline' https: http:;report-uri https://csp.withgoogle.com/csp/gws/other-hp
    date: Tue, 27 Feb 2024 09:31:02 GMT
    expires: Thu, 28 Mar 2024 09:31:02 GMT
    cache-control: public, max-age=2592000
    server: gws
    content-length: 220
    x-xss-protection: 0
    x-frame-options: SAMEORIGIN
    alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000

    <HTML>
    <HEAD>
      <meta http-equiv="content-type" content="text/html;charset=utf-8">
      <TITLE>301 Moved</TITLE>
    </HEAD>
    <BODY>
      <H1>301 Moved</H1>
      The document has moved
      <A HREF="https://www.google.com/">here</A>
      .
    </BODY>
    </HTML>

[15:00:53.897][127.0.0.1:38826] client disconnect
[15:00:53.897][127.0.0.1:38826] server disconnect google.com:443 (142.250.183.238:443)
```
</details>

Content is not truncated within `3` lines

#### After

<details>
<summary>Output</summary>

```
[14:55:26.042] HTTP(S) proxy listening at *:8080.
[14:55:33.630][127.0.0.1:40554] client connect
[14:55:33.775][127.0.0.1:40554] server connect google.com:443 (142.250.182.142:443)
127.0.0.1:40554: GET https://google.com/ HTTP/2.0
    user-agent: curl/8.5.0
    accept: */*

 << HTTP/2.0 301 Moved Permanently 220b
    location: https://www.google.com/
    content-type: text/html; charset=UTF-8
    content-security-policy-report-only: object-src 'none';base-uri 'self';script-src 'nonce-LCd_ThPYwSImYoighASUFQ' 'strict-dynamic' 'report-sample' 'unsafe-eval' 'unsafe-inline' https: http:;report-uri https://csp.withgoogle.com/csp/gws/other-hp
    date: Tue, 27 Feb 2024 09:25:42 GMT
    expires: Thu, 28 Mar 2024 09:25:42 GMT
    cache-control: public, max-age=2592000
    server: gws
    content-length: 220
    x-xss-protection: 0
    x-frame-options: SAMEORIGIN
    alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000

    <HTML>
    <HEAD>
      <meta http-equiv="content-type" content="text/html;charset=utf-8">
    (cut off)

[14:55:34.021][127.0.0.1:40554] client disconnect
[14:55:34.022][127.0.0.1:40554] server disconnect google.com:443 (142.250.182.142:443)
```
</details>

Content is truncated within `3` lines

#### Checklist

 - [x] I have updated tests where applicable.
 - [x] I have added an entry to the CHANGELOG.

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-02-27 12:50:25 +01:00
Mike Anselmi 3ba4b65ecd
Fix ca_file containing multiple CAs (#6666)
#### Description

Unfortunately 0b5e310881 broke mitmproxy's
ability to issue leaf certificates if `ca_file` contains multiple CAs.
This PR restores that capability.

The issue lies in `mitmproxy/certs.py` - specifically, in the
`from_files` method of the `CertStore` class. Before
0b5e310881, the issuing CA was identified
like this:

``` python
raw = ca_file.read_bytes()
key = load_pem_private_key(raw, passphrase)
…
certs = re.split(rb"(?=-----BEGIN CERTIFICATE-----)", raw)
ca = Cert.from_pem(certs[1])
```

This worked even when `ca_file` contained multiple CAs. For example,
consider this example:

```
-----BEGIN PRIVATE KEY-----
REDACTED
-----END PRIVATE KEY-----
-----BEGIN CERTIFICATE-----
MIICmTCCAfqgAwIBAgIRAIqaBJ6aU5wXT+5JAn8Uj1IwCgYIKoZIzj0EAwQwMDEu
MCwGA1UEAxMlbWFuc2VsbWkgSW50ZXJtZWRpYXRlIENBICgyMDIzLTA0LTExKTAe
Fw0yNDAyMTQxNzEzMDBaFw0yNDAyMTUxNzE0MDBaMB8xHTAbBgNVBAMTFG1pdG1w
cm94eSBJc3N1aW5nIENBMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEeKTLpy6KeiWN
89S9UJoTM9w6HyrEiVByf/ie2wUX3vR/3nHVMTi5XZQD6/8h3A9yUWwtRtVDj55D
STbPKjN6G8t/Qh1dGz2vanNjmWNlceM3DOIlT30vmR5+GrUOwj+7o4HoMIHlMA4G
A1UdDwEB/wQEAwIBhjAdBgNVHSUEFjAUBggrBgEFBQcDAgYIKwYBBQUHAwEwEgYD
VR0TAQH/BAgwBgEB/wIBADAdBgNVHQ4EFgQUkf9kgx5DbP0B66Ir6oLUDV/CIU4w
HwYDVR0jBBgwFoAUqBYQLb8rkIidwq5dYuiDFdKhY48wYAYMKwYBBAGCpGTGKEAB
BFAwTgIBAQQcbWlrZUBtYW5zZWxtaS5jb206aXNzdWluZy1jYQQrYmZhODBJaGMz
VXNUcU0yQlp6ZG1rYW1OLW1XNGtpWTJrM1g5X19kd3Q0bzAKBggqhkjOPQQDBAOB
jAAwgYgCQgF/QLZ0cThJKeoeIk4dY4+Z2MdIey7kvvy1jwlWrsOqOY+UXUWHXRlj
oXZN92imAKqgLU5T859MMqWrjA1LjN7w6QJCAY+2xN7ovry3WSMqwnu86NuPL8vh
fjftZeIW5GWuLzOsEFt7SfWMhkmFc/jcFpZ/qlolPhvr6E170zNhHUSMKvjb
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIICcjCCAdSgAwIBAgIQeK+VyMjx85py1kqGdjn5nTAKBggqhkjOPQQDBDAoMSYw
JAYDVQQDEx1tYW5zZWxtaSBSb290IENBICgyMDIzLTA0LTExKTAeFw0yMzA0MTEw
MjIzMzdaFw0yODA0MDkwMjIzMzdaMDAxLjAsBgNVBAMTJW1hbnNlbG1pIEludGVy
bWVkaWF0ZSBDQSAoMjAyMy0wNC0xMSkwgZswEAYHKoZIzj0CAQYFK4EEACMDgYYA
BADhbjtnME8IDpBab8MogM0HchH0V9B8Qx7nRXK+tbGyyHlgLjIBYF/erJGBP0md
RMAxU5x/nPlHPODRBkJhB0wbcwGC9zjQQyxfhG75806QzkaZSsC0kFZ9d3JG4fjn
uenY1S2VZ5qE0gDc8Qmfyjcx7KqxQKwS9RwtG1ymAmWgvmGIJ6OBlDCBkTAOBgNV
HQ8BAf8EBAMCAQYwEgYDVR0TAQH/BAgwBgEB/wIBATAdBgNVHQ4EFgQUqBYQLb8r
kIidwq5dYuiDFdKhY48wHwYDVR0jBBgwFoAU6+JptrrPiOuWZyKvwg0EJz5TkW8w
KwYDVR0fBCQwIjAgoB6gHIYaaHR0cDovL2NhLm1hbnNlbG1pLmNvbS9jcmwwCgYI
KoZIzj0EAwQDgYsAMIGHAkEw/A2kiL4Kt9/8PND89vlXEehqeymFgats62a3UMU2
g3zATES/WI2E1IgqIsmB6ILRgWMslzpH+NGP+JJkFCz9cwJCAJaRlnOc3xafHZta
0Xwr5YUVAAfmVOj9a2XAsNlNuMy2t8cmeeGmQjrZwCuivlzLOp19Ge3Mi0dnzeV+
5L2rBOCL
-----END CERTIFICATE-----
```

`certs` would have three elements: the private key, the issuing CA and
the intermediate CA. As a result, `ca = Cert.from_pem(certs[1])` would
select the first CA (the issuing CA).

From 0b5e310881 onward, we instead have

``` python
raw = ca_file.read_bytes()
key = load_pem_private_key(raw, passphrase)
…
certs = x509.load_pem_x509_certificates(raw)
ca = Cert(certs[-1])
```

Now, `certs` would have only two elements: the issuing CA and the
intermediate CA. (`x509.load_pem_x509_certificates` discards the private
key.) As a result, `ca = Cert(certs[-1])` must instead be `ca =
Cert(certs[0])`, otherwise the `ca` and `key` won't correspond to each
other and we'll eventually see an error like this when mitmproxy tries
to generate a leaf certificate:

```
Addon error: [('x509 certificate routines', '', 'key values mismatch')]
Traceback (most recent call last):
  File "/Users/manselmi/repos/mitmproxy/mitmproxy/addons/tlsconfig.py", line 208, in tls_start_client
    tls_start.ssl_conn.use_privatekey(
  File "/Users/manselmi/virtualenv/mitmproxy-py312/lib/python3.12/site-packages/OpenSSL/SSL.py", line 1949, in use_privatekey
    self._context._raise_passphrase_exception()
  File "/Users/manselmi/virtualenv/mitmproxy-py312/lib/python3.12/site-packages/OpenSSL/SSL.py", line 1123, in _raise_passphrase_exception
    _raise_current_error()
  File "/Users/manselmi/virtualenv/mitmproxy-py312/lib/python3.12/site-packages/OpenSSL/_util.py", line 57, in exception_from_error_queue
    raise exception_type(errors)
OpenSSL.SSL.Error: [('x509 certificate routines', '', 'key values mismatch')]
```
2024-02-16 19:37:24 +00:00
basedBaba 1f2e1a254a
fix: generate wireguard config with correct endpoint when using two or more active nics (#6659)
#### Description

Fix issue #6656

This generates a wireguard config with the correct endpoint when using
two or more active NICs.
 
#### Checklist

 - [x] I have updated tests where applicable.
 - [x] I have added an entry to the CHANGELOG.

---------

Co-authored-by: Maximilian Hils <github@maximilianhils.com>
2024-02-14 09:39:29 +00:00
Sujal Singh d317304268
Remove duplicate answers in DNS queries (#6648)
#### Description

Fixes #6647 by assuming all DNS queries are made over UDP, will need to
be reworked when TCP support is added.

#### Checklist

 - [x] I have updated tests where applicable.
 - [x] I have added an entry to the CHANGELOG.
2024-02-13 10:58:34 +01:00
Maximilian Hils 6bd19a77e2
build macOS arm64 binaries (#6633) 2024-01-31 23:20:19 +00:00
Maximilian Hils 6afa7081e8
fix CHANGELOG 2024-01-31 23:44:02 +01:00
basedBaba ec96b98f7f
fix: save failed connect request urls to har files correctly (#6599) 2024-01-31 23:37:39 +01:00
dq 865e1138da
fix IPv6 matches against the full host:port string (#6614) 2024-01-23 20:29:24 +00:00
mitmproxy release bot d75dc95a1e mitmproxy 10.2.2 2024-01-21 17:09:27 +00:00
Louis 09f4719711
allow_hosts/ignore_hosts option now matches against the full `host:port` string (#6594)
Co-authored-by: Maximilian Hils <git@maximilianhils.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-01-21 17:07:14 +00:00
Maximilian Hils c6defba77d
websockets: do not process start event before redirecting event handlers (#6609)
fix #6608
2024-01-21 13:53:02 +00:00
Maximilian Hils 08eb515635
fix client playback (#6605) 2024-01-17 17:58:35 +01:00
Maximilian Hils 8fc114a9b2
fix CHANGELOG 2024-01-08 08:54:48 +01:00
Daniel López Guimaraes c2dd0d5a42
savehar: Fix timings being set to null (#6578) 2024-01-07 10:48:50 -08:00
mitmproxy release bot a7edbdf74c mitmproxy 10.2.1 2024-01-06 14:17:25 +00:00