Skip to content

proposal: x/crypto/ssh: export structured disconnect message / reason error #39259

Open
@jayschwa

Description

@jayschwa

What version of Go are you using (go version)?

$ go version
go version go1.14.3 linux/amd64

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/jayschwa/.cache/go-build"
GOENV="/home/jayschwa/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/jayschwa/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/snap/go/5759"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/snap/go/5759/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/jayschwa/golang-crypto/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build549371117=/tmp/go-build -gno-record-gcc-switches"

Proposal

The SSH protocol defines disconnect reason codes in section 11.1 of RFC 4253. I have an application where I want to inspect the disconnect reason code. I currently do this by checking the error string, but this is considered a bad practice.

Internally, the x/crypto/ssh package contains a disconnectMsg error type that is the structured form of the disconnect reason data. However, that type is not exposed externally for use with a function such as errors.As. I propose that disconnectMsg (or something like it) be exported so that users may unwrap the error and inspect the reason code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ProposalProposal-CryptoProposal related to crypto packages or other security issues

    Type

    No type

    Projects

    Status

    Incoming

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions