go.crypto/ssh: introduce Signer method, an abstraction of
private keys. R=agl, jpsugar, jonathan.mark.pittman CC=golang-dev https://golang.org/cl/13338044
This commit is contained in:
committed by
Adam Langley
parent
28dc961a18
commit
934c14ffe9
+6
-2
@@ -23,14 +23,18 @@ func ExampleListen() {
|
||||
},
|
||||
}
|
||||
|
||||
pemBytes, err := ioutil.ReadFile("id_rsa")
|
||||
privateBytes, err := ioutil.ReadFile("id_rsa")
|
||||
if err != nil {
|
||||
panic("Failed to load private key")
|
||||
}
|
||||
if err = config.SetRSAPrivateKey(pemBytes); err != nil {
|
||||
|
||||
private, err := ParsePrivateKey(privateBytes)
|
||||
if err != nil {
|
||||
panic("Failed to parse private key")
|
||||
}
|
||||
|
||||
config.AddHostKey(private)
|
||||
|
||||
// Once a ServerConfig has been configured, connections can be
|
||||
// accepted.
|
||||
listener, err := Listen("tcp", "0.0.0.0:2022", config)
|
||||
|
||||
Reference in New Issue
Block a user