Fix a crash when a certificate is added into the known hosts file

Typically this crash only happened at the point when the connection that
presented that certificate was closed.