Skip to content
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

Unable to set OmitEmptyPsk in PreSharedKeyExtension #255

Closed
sleeyax opened this issue Oct 12, 2023 · 3 comments
Closed

Unable to set OmitEmptyPsk in PreSharedKeyExtension #255

sleeyax opened this issue Oct 12, 2023 · 3 comments

Comments

@sleeyax
Copy link
Contributor

sleeyax commented Oct 12, 2023

Not sure if this is considered a bug, but setting OmitEmptyPsk to true in the PreSharedKeyExtension as part of a custom ClientHelloSpec has no effect:

spec := &utls.ClientHelloSpec{
    Extensions: []utls.TLSExtension{
        // ...
        &utls.UtlsPreSharedKeyExtension{
            OmitEmptyPsk: true,
        },
    },
}

The only way to actually enable OmitEmptyPsk is by specifying it in the UConn config:

tlsConfig := &utls.Config{OmitEmptyPsk: true}
conn := utls.UClient(rawConn, tlsConfig, tls.HelloCustom)
// ...

Because it's overwritten in:

s.pskExtension.SetOmitEmptyPsk(s.uconnRef.config.OmitEmptyPsk)

I think this can be fixed/clarified by either making this field private in the extension or by following the configuration in both parts of the code.

Edit: At the time of writing, I'm using the master branch with commit 3546fd9 as the latest change.

@gaukas
Copy link
Contributor

gaukas commented Oct 13, 2023

Interesting observation. I think it might worth it if we comment/deprecate on this feature. Apparently we no longer want to remove this exported field since that's already a part of the uTLS API and removing it breaks anyone using an older version and (mistakenly) uses this field in the extension.

@sleeyax
Copy link
Contributor Author

sleeyax commented Oct 13, 2023

Ah I see. I can create a PR for this small improvement if you like.

How about adding a deprecation comment to both UtlsPreSharedKeyExtension and FakePreSharedKeyExtension structs like this?

type UtlsPreSharedKeyExtension struct {
	// ...

	// Deprecated: Set OmitEmptyPsk in Config instead.
	OmitEmptyPsk bool
}

@gaukas
Copy link
Contributor

gaukas commented Oct 13, 2023

That would be nice! Thanks for doing that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants