Differentiate between unknown and untrusted certificates
This commit is contained in:
parent
fc96076472
commit
bf3e6b3c5c
30
README.md
30
README.md
@ -51,9 +51,9 @@ clients. Here is a simple client using TOFU to authenticate certificates:
|
|||||||
```go
|
```go
|
||||||
client := &gemini.Client{
|
client := &gemini.Client{
|
||||||
KnownHosts: gemini.LoadKnownHosts(".local/share/gemini/known_hosts"),
|
KnownHosts: gemini.LoadKnownHosts(".local/share/gemini/known_hosts"),
|
||||||
TrustCertificate: func(cert *x509.Certificate, knownHosts *gemini.KnownHosts) bool {
|
TrustCertificate: func(cert *x509.Certificate, knownHosts *gemini.KnownHosts) error {
|
||||||
// If the certificate is in the known hosts list, allow the connection
|
// If the certificate is in the known hosts list, allow the connection
|
||||||
if knownHosts.Has(cert) {
|
if err := knownHosts.Lookup(cert); {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
// Prompt the user
|
// Prompt the user
|
||||||