Fix hosts not being added to known hosts file
This commit is contained in:
parent
c4af352e87
commit
32a9fcba0c
|
@ -37,7 +37,7 @@ func init() {
|
||||||
return nil
|
return nil
|
||||||
} else if userTrustsCertificatePermanently() {
|
} else if userTrustsCertificatePermanently() {
|
||||||
// Add the certificate to the known hosts file
|
// Add the certificate to the known hosts file
|
||||||
knownHosts.Add(cert)
|
knownHosts.Add(req.Hostname(), cert)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
7
tofu.go
7
tofu.go
|
@ -60,17 +60,14 @@ func (k *KnownHosts) LoadFrom(path string) error {
|
||||||
|
|
||||||
// Add adds a certificate to the list of known hosts.
|
// Add adds a certificate to the list of known hosts.
|
||||||
// If KnownHosts was loaded from a file, Add will append to the file.
|
// If KnownHosts was loaded from a file, Add will append to the file.
|
||||||
func (k *KnownHosts) Add(cert *x509.Certificate) {
|
func (k *KnownHosts) Add(hostname string, cert *x509.Certificate) {
|
||||||
// Add an entry per hostname
|
host := NewKnownHost(hostname, cert)
|
||||||
for _, name := range cert.DNSNames {
|
|
||||||
host := NewKnownHost(name, cert)
|
|
||||||
k.hosts = append(k.hosts, host)
|
k.hosts = append(k.hosts, host)
|
||||||
// Append to the file
|
// Append to the file
|
||||||
if k.file != nil {
|
if k.file != nil {
|
||||||
host.Write(k.file)
|
host.Write(k.file)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Lookup looks for the provided certificate in the list of known hosts.
|
// Lookup looks for the provided certificate in the list of known hosts.
|
||||||
// If the hostname is in the list, but the fingerprint differs,
|
// If the hostname is in the list, but the fingerprint differs,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user