Move tofu.go to a subpackage

This commit is contained in:
Adnan Maolood 2021-01-10 16:44:32 -05:00
parent 1f2888c54a
commit d78052ce08
2 changed files with 5 additions and 3 deletions

View File

@ -17,11 +17,12 @@ import (
"time" "time"
"git.sr.ht/~adnano/go-gemini" "git.sr.ht/~adnano/go-gemini"
"git.sr.ht/~adnano/go-gemini/tofu"
"git.sr.ht/~adnano/go-xdg" "git.sr.ht/~adnano/go-xdg"
) )
var ( var (
hosts gemini.KnownHostsFile hosts tofu.KnownHostsFile
scanner *bufio.Scanner scanner *bufio.Scanner
) )
@ -46,7 +47,7 @@ Otherwise, this should be safe to trust.
=> ` => `
func trustCertificate(hostname string, cert *x509.Certificate) error { func trustCertificate(hostname string, cert *x509.Certificate) error {
fingerprint := gemini.NewFingerprint(cert.Raw, cert.NotAfter) fingerprint := tofu.NewFingerprint(cert.Raw, cert.NotAfter)
knownHost, ok := hosts.Lookup(hostname) knownHost, ok := hosts.Lookup(hostname)
if ok && time.Now().Before(knownHost.Expires) { if ok && time.Now().Before(knownHost.Expires) {
// Check fingerprint // Check fingerprint

View File

@ -1,4 +1,5 @@
package gemini // Package tofu implements trust on first use using hosts and fingerprints.
package tofu
import ( import (
"bufio" "bufio"