You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (go version)?
1.6.2
What operating system and processor architecture are you using (go env)?
linux/amd64
What did you do?
Set a custom callback for ClientConfig HostKeyCallback
What did you expect to see?
My own error when creating a client connection that failed due to my HostKeyCallback.
The server returns the error as-is https://github.com/golang/crypto/blob/master/ssh/server.go#L151
I wrongly assumed my error would be passed through in a similar fashion to how Bolt's API works, so this isn't a bug/issue so much as it is a small feature request.
So currently in the error I return from my HostKeyCallback I set additional information I'd like to retrieve later when making a client connection. Currently this is difficult because the error is always wrapped by fmt.Errorf at the line above. I know I can set additional state in my function (maybe a map with a mutex) or run a regex against the returned error to see if it contains my error, but neither of those seemed very good.
My idea is to add a simple HandshakeError type that saves a reference to the original error and is returned in the client handshake (maybe the sever handshake too). Something like this https://play.golang.org/p/EjM5ijecz3
There are already other Error types in that package, and this one would print the same output if someone was expecting it. Alternatively removing the fmt.Errorf call would work, and would match how the ssh server returns the error from its handshake, which ever is best.
The text was updated successfully, but these errors were encountered:
That would be nice. Is this something that can be included in another commit due to it being a single line change? Or should I do it and go through the contribution guidelines? Thanks
Please answer these questions before submitting your issue. Thanks!
go version
)?1.6.2
go env
)?linux/amd64
Set a custom callback for ClientConfig HostKeyCallback
My own error when creating a client connection that failed due to my HostKeyCallback.
The server returns the error as-is
https://github.com/golang/crypto/blob/master/ssh/server.go#L151
I wrongly assumed my error would be passed through in a similar fashion to how Bolt's API works, so this isn't a bug/issue so much as it is a small feature request.
A new "generic" error wrapped by fmt.Errorf
https://github.com/golang/crypto/blob/master/ssh/client.go#L77
So currently in the error I return from my HostKeyCallback I set additional information I'd like to retrieve later when making a client connection. Currently this is difficult because the error is always wrapped by fmt.Errorf at the line above. I know I can set additional state in my function (maybe a map with a mutex) or run a regex against the returned error to see if it contains my error, but neither of those seemed very good.
My idea is to add a simple HandshakeError type that saves a reference to the original error and is returned in the client handshake (maybe the sever handshake too). Something like this
https://play.golang.org/p/EjM5ijecz3
There are already other Error types in that package, and this one would print the same output if someone was expecting it. Alternatively removing the fmt.Errorf call would work, and would match how the ssh server returns the error from its handshake, which ever is best.
The text was updated successfully, but these errors were encountered: