Thanks again for your clarifications @DTS Engineer!
Here is the flow I am thinking to follow with my existing app so far:
Network Traffic
│
NETransparentProxyProvider
│
├─ Detect Protocol (first bytes)
│
├─ HTTP ─────> HTTPFlowLogger (existing)
│
└─-------- HTTPS
│
TLS Interceptor (NEW)
│
┌─────---───────────────┐
│ │
Client TLS Server TLS
(terminate) (re-initiate)
│ │
└──── Decrypted Bytes ─----┘
│
HTTPFlowLogger (reuse)
To start with, I am thinking of something basic: Supporting all HTTP/1.1 traffic so that I can reuse my existing HTTP parser.
Is it possible to downgrade(at least a part of) HTTPS traffic without loosing anything while doing so? What can I expect in terms of complexity and performance here?
Now, As you've mentioned:
Keep in mind that the world has moved on from HTTP/1. A good TLS inspection product should support HTTP/2 + TLS + TCP and HTTP/3 + QUIC + DTLS + UDP
To support at least HTTP/2 + TLS + TCP(as I think most of the traffic these days), What's the best approach in this scenario?
Once I get the flow from
override func handleNewFlow(_ flow: NEAppProxyFlow) -> Bool { .....
I just branch to the specific handler based on ALPN extraction. Something like:
private func classifyTLS(_ info: TLSClientHelloInfo) -> String {
if info.alpnProtocols.contains("h2") {
return "HTTP_2"
}
if info.alpnProtocols.contains("http/1.1") {
return "HTTP_1_1"
}
return "UNKNOWN"
}
Where TLSClientHelloInfo is a struct:
struct TLSClientHelloInfo {
let serverName: String?
let version: UInt16
let alpnProtocols: [String]
}
Now, for parsing HTTPS traffic of the kind HTTP/2 + TCP:
Is it a good idea to use the SwiftNIO SSL library: NIO HTTP2
or
NIO HTTP?
What kind of issues I need to be prepared if I follow this approach in my System Extension Xcode target?
Also, I can see multiple protocols when I just printed in some cases. Once I extracted, it has h2 and http/1.1. Now, Is it possible to downgrade the HTTPS traffic to just http/1.1 without loosing anything or we are going to face compatibility/anyother issues?
I need to handle up to HTTP/2, at the very least, to cover majority of HTTPS traffic, right?
And overall, how practical and achievable, the approach I am thinking?
Thanks a lot for continuous support here.
Topic:
App & System Services
SubTopic:
Networking
Tags: