service: add a way to reset a network certfp

This commit is contained in:
Simon Ser 2023-08-09 18:04:30 +02:00
parent 97cfb366b0
commit fc1151326c
2 changed files with 5 additions and 2 deletions

View File

@ -258,7 +258,8 @@ character.
Instead of using certificate authorities to check the server's TLS Instead of using certificate authorities to check the server's TLS
certificate, check whether the server certificate matches the provided certificate, check whether the server certificate matches the provided
fingerprint. This can be used to connect to servers using self-signed fingerprint. This can be used to connect to servers using self-signed
certificates. The fingerprint format is SHA512. certificates. The fingerprint format is SHA512. An empty string
removes any previous fingerprint.
*-nick* <nickname> *-nick* <nickname>
Connect with the specified nickname. By default, the account's username Connect with the specified nickname. By default, the account's username

View File

@ -530,7 +530,9 @@ func (fs *networkFlagSet) update(network *database.Network) error {
if _, err := hex.DecodeString(certFP); err != nil { if _, err := hex.DecodeString(certFP); err != nil {
return fmt.Errorf("the certificate fingerprint must be hex-encoded") return fmt.Errorf("the certificate fingerprint must be hex-encoded")
} }
if len(certFP) == 64 { if len(certFP) == 0 {
network.CertFP = ""
} else if len(certFP) == 64 {
network.CertFP = "sha-256:" + certFP network.CertFP = "sha-256:" + certFP
} else if len(certFP) == 128 { } else if len(certFP) == 128 {
network.CertFP = "sha-512:" + certFP network.CertFP = "sha-512:" + certFP