utls icon indicating copy to clipboard operation
utls copied to clipboard

Consider adding MarshalJson support for ClientHelloSpec

Open let4be opened this issue 2 years ago • 5 comments

Hi! Looks like utls can unmarshal ClientHelloSpec from client.tlsfingerprint.io format

Could be useful to support marshalling/unmarshalling to/from arbitrary json, or at least marshalling to client.tlsfingerprint.io format

let4be avatar Sep 13 '23 07:09 let4be

Actually JSON import/export was a planned feature. But currently only partially completed due to my limited capacity. I want to clarify that it is not abandoned or deserted, but still "coming soon".

client.tlsfingerprint.io format

I would love to point out that client.tlsfingerprint.io currently does not parse enough details and what's provided there could be less than enough to rebuild a complete ClientHelloSpec when a few new extensions are included (PSK, ALPS, etc). You can see in testdata we have some pre-built JSON which does not look like the response from client.tlsfingerprint.io. Those are actually the proposed JSON ClientHelloSpec.

gaukas avatar Sep 14 '23 02:09 gaukas

With that said, I guess we all would be happy to see if anyone volunteers to take over the development of this feature.

gaukas avatar Sep 14 '23 02:09 gaukas

Do we need to keep compatibility with client.tlsfingerprint.io? It's json and would complicate adding normal readable json support(current impl of client.tlsfingerprint.io expects binary data in extensions ) afaik

let4be avatar Sep 14 '23 05:09 let4be

Importing from client.tlsfingerprint.io was (supposed to be) done by (*ClientHelloSpec).ImportTLSClientHello. It will no longer work now given the client.tlsfingerprint.io has been changed (moved to use clienthellod), but the corresponding updates are welcome.

But again clienthellod doesn't capture every single details in the clienthello either so I doubt if you can really build a complete ClientHelloSpec from what you see on client.tlsfingerprint.io.

gaukas avatar Sep 14 '23 06:09 gaukas

So, in short, no. JSON here does not refer to client.tlsfingerprint.io, and should not be compatible with it. The original plan is building a JSON-exporter to replace the old UTLS code generator on tlsfingerprint.io.

gaukas avatar Sep 14 '23 06:09 gaukas