-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
question: TLS example #687
Comments
I used the method available at https://github.com/google/gopacket/blob/master/layers/tls_test.go. if tls, ok := p.Layer(layers.LayerTypeTLS).(*layers.TLS); ok {
fmt.Printf("work: ", tls)
} else {
t.Error("doesn't work -- No TLS layer type found in packet")
} Returns |
UPDATE: See comment below for automatically decoding TLS from a PacketSource Can confirm that live packet capture doesn't automatically decode TLS layers. Right now, I have to manually decode it w/ the following code:
|
I contributed with this layer because I needed it for my tool. You can see a basic example on in: https://github.com/jselvi/fiesta/blob/master/pkg/tlsrelay/tls.go#L28 I implemented this some time ago and I can't remember the details, but I tried to mimic the decisions that were taken in other layers, so you shouldn't see a different behaviour. |
@jselvi Thanks |
So I identified why this behavior is occuring. If you want to automatically decode TLS layers from a packet source (pcap or handle), you need to set As explained by the documentation for DecodeStreamsAsDatagrams:
And the relevant lines of code from
|
Oh, I see. But this is something that should happen with every application layer, not only TLS. I understood that this was a problem not happening when decoding packet containing an application layer other than TLS. Btw, that flag is set to true in the tests: Line 224 in 2d7fab0
Thanks @spitfire55 ! |
The reason for this is that TCP carries a stream of data and not datagrams. This means that single TCP packets do not generally carry single payloads. E.g., for TLS, if you're lucky one TCP packet will contain a single TLS record - but in many cases one TCP packet will contain:
So the correct way to go about this would be to use reassembly, and then pull the tls records out of the reassembled stream. This problem also exists for the other TCP payloads and is the reason why #587 and #584 are not yet implemented (we don't have some kind of mechanism to somehow mix reassembly and packets, and a mechanism for implementing stream based protocols that can consume a reassembled stream). |
Hello. I see the TLS layer has merged to master but there is no example to reference.
It would be good if gopacket provides the TLS example.
Many thanks:)
The text was updated successfully, but these errors were encountered: