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

crypto/tls: add VersionName function to return a string version of the TLS Version #46308

Open
skgsergio opened this issue May 21, 2021 · 12 comments · May be fixed by #46309
Open

crypto/tls: add VersionName function to return a string version of the TLS Version #46308

skgsergio opened this issue May 21, 2021 · 12 comments · May be fixed by #46309
Assignees
Labels
FeatureRequest NeedsFix Proposal Proposal-Accepted Proposal-FinalCommentPeriod
Projects
Milestone

Comments

@skgsergio
Copy link

@skgsergio skgsergio commented May 21, 2021

I propose to add a func VersionName(version uint16) string method that returns a string representation (TLSv1.0, TLSv1.1, ...) given a version id.

Currently crypto/tls provides similar functionality for the cipher suites but not for the version. I've seen myself and others implementing this in our codes to print it in logs and other places, but this is far from ideal as, for example, if a new protocol is added in the future, that code would be outdated.

I couldn't find any related issue or ongoing work so I'll be opening a PR.

skgsergio added a commit to skgsergio/go that referenced this issue May 21, 2021
This function returns an string representation (`TLSv1.0`, `TLSv1.1`, ...)
given a TLS version number.

Fixes golang#46308
@skgsergio skgsergio linked a pull request May 21, 2021 that will close this issue
skgsergio added a commit to skgsergio/go that referenced this issue May 21, 2021
This function returns an string representation (`TLSv1.0`, `TLSv1.1`, ...)
given a TLS version number.

Fixes golang#46308
@gopherbot
Copy link

@gopherbot gopherbot commented May 21, 2021

Change https://golang.org/cl/321733 mentions this issue: crypto/tls: add crypto/tls.VersionName function

@dmitshur dmitshur added FeatureRequest NeedsInvestigation labels May 21, 2021
@dmitshur dmitshur added this to the Backlog milestone May 21, 2021
@dmitshur
Copy link
Contributor

@dmitshur dmitshur commented May 21, 2021

@networkimprov
Copy link

@networkimprov networkimprov commented May 24, 2021

cc @ianlancetaylor re likely proposal

@ianlancetaylor ianlancetaylor changed the title crypto/tls: Add VersionName to return a string version of the TLS Version crypto/tls: add VersionName function to return a string version of the TLS Version May 24, 2021
@ianlancetaylor ianlancetaylor changed the title crypto/tls: add VersionName function to return a string version of the TLS Version proposal: crypto/tls: add VersionName function to return a string version of the TLS Version May 24, 2021
@ianlancetaylor ianlancetaylor removed this from the Backlog milestone May 24, 2021
@ianlancetaylor ianlancetaylor added this to the Proposal milestone May 24, 2021
@ianlancetaylor ianlancetaylor added this to Incoming in Proposals May 24, 2021
@rsc
Copy link
Contributor

@rsc rsc commented Nov 10, 2021

@rsc
Copy link
Contributor

@rsc rsc commented Nov 10, 2021

This proposal has been added to the active column of the proposals project
and will now be reviewed at the weekly proposal review meetings.
— rsc for the proposal review group

@rsc rsc moved this from Incoming to Active in Proposals Nov 10, 2021
@rsc
Copy link
Contributor

@rsc rsc commented Dec 1, 2021

@rolandshoemaker
Copy link
Member

@rolandshoemaker rolandshoemaker commented Dec 1, 2021

Generally seems reasonable.

@rsc
Copy link
Contributor

@rsc rsc commented Dec 8, 2021

Based on the discussion above, this proposal seems like a likely accept.
— rsc for the proposal review group

@rsc rsc moved this from Active to Likely Accept in Proposals Dec 8, 2021
@rsc rsc moved this from Likely Accept to Accepted in Proposals Dec 15, 2021
@rsc
Copy link
Contributor

@rsc rsc commented Dec 15, 2021

No change in consensus, so accepted. 🎉
This issue now tracks the work of implementing the proposal.
— rsc for the proposal review group

@rsc rsc changed the title proposal: crypto/tls: add VersionName function to return a string version of the TLS Version crypto/tls: add VersionName function to return a string version of the TLS Version Dec 15, 2021
@rsc rsc removed this from the Proposal milestone Dec 15, 2021
@rsc rsc added this to the Backlog milestone Dec 15, 2021
@FiloSottile FiloSottile removed this from the Backlog milestone Mar 2, 2022
@FiloSottile FiloSottile added this to the Go1.19 milestone Mar 2, 2022
@FiloSottile FiloSottile self-assigned this Mar 2, 2022
@dmitshur dmitshur added NeedsFix and removed NeedsInvestigation labels Mar 5, 2022
@mvdan
Copy link
Member

@mvdan mvdan commented Mar 14, 2022

Was a String method considered? I imagine that the problem might be that making the constants use a named type rather than be left as untyped integers might break some users, but I can't help but feel like a top-level "to string" function feels out of place :)

@FiloSottile
Copy link
Contributor

@FiloSottile FiloSottile commented Mar 14, 2022

Is there a way to convert the constants to a named type within the Go 1 Compatibility Promise?

@mt-inside
Copy link

@mt-inside mt-inside commented Mar 24, 2022

If there could be a named type someone, a String() method (and thereby satisfying fmt.Stringer) would play very nicely with go 1.18 generics...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FeatureRequest NeedsFix Proposal Proposal-Accepted Proposal-FinalCommentPeriod
Projects
Proposals
Accepted
Development

Successfully merging a pull request may close this issue.

10 participants