File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ package knownhosts
2
+
3
+ import (
4
+ "io"
5
+
6
+ "golang.org/x/crypto/ssh"
7
+ )
8
+
9
+ func NewFromReader (r io.Reader ) (ssh.HostKeyCallback , error ) {
10
+ db := newHostKeyDB ()
11
+ if err := db .Read (r , "" ); err != nil {
12
+ return nil , err
13
+ }
14
+
15
+ var certChecker ssh.CertChecker
16
+ certChecker .IsHostAuthority = db .IsHostAuthority
17
+ certChecker .IsRevoked = db .IsRevoked
18
+ certChecker .HostKeyFallback = db .check
19
+
20
+ return certChecker .CheckHostKey , nil
21
+ }
Original file line number Diff line number Diff line change
1
+ package knownhosts
2
+
3
+ import (
4
+ "fmt"
5
+ "strings"
6
+ "testing"
7
+ )
8
+
9
+ func TestNewFromReader (t * testing.T ) {
10
+ str := fmt .Sprintf ("server*.domain %s" , edKeyStr )
11
+
12
+ _ , err := NewFromReader (strings .NewReader (str ))
13
+ if err != nil {
14
+ t .Fatalf ("cannot read from string: %v" , err )
15
+ }
16
+
17
+ }
You can’t perform that action at this time.
0 commit comments