Repository navigation
Inspect HTTPS request and response bodies with a trusted CA - #22
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Netkit currently records CONNECT establishment but cannot show the encrypted requests inside a tunnel. Add opt-in
serve --inspect-https --ca-cert ... --ca-key ...to inspect all proxied destinations when clients trust the supplied CA. The existing dashboard and history API display decrypted URLs, headers, and request/response bodies.netkit cagenerates a persistent CA without overwriting existing files, with a private key mode of 0600. Origin certificate verification stays enabled. The interception path preserves keep-alive, redirects, OPTIONS, cancellation, streaming responses/SSE, and Node fetch's plaintext CONNECT behavior. Shutdown closes inspected tunnels.Validation:
go test -race ./..., existinggo test -tags=e2e ./test/e2e,golangci-lint run ./..., CLI build, and diff checks passed. Integration tests exercise HTTPS body capture, trust rejection on both sides, DNS/IP certificates, streaming, redirects, plaintext CONNECT, and shutdown. A real curl HTTPS POST through the built CLI returned 200; history contained the dummy JSON request and matching response body.Inspection negotiates HTTP/1.1. WebSocket/protocol upgrades return 501; frame inspection is outside this change. Complete bodies are kept in memory, including credentials, and stream records appear at completion/disconnection. README includes CA setup and client trust instructions. This PR adds the inspection capability; deployments must configure their clients to trust the CA.