Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion internal/tmpbbs/pullpeer.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"context"
"crypto/tls"
"crypto/x509"
"errors"
"fmt"
"log/slog"
"os"
"strings"
Expand All @@ -31,6 +33,10 @@ type pullPeer struct {

const minClientTimeout = 15 * time.Second

// ErrTrustedCAParsing is caused by failure to parse any trusted CA
// certificates from a PEM file.
var ErrTrustedCAParsing = errors.New("error parsing trusted CA certificates")

func newPullPeer(address string, caCertPool *x509.CertPool, interval time.Duration,
postStore *PostStore,
) (*pullPeer, error) {
Expand Down Expand Up @@ -164,7 +170,9 @@ func RunPullPeers(addresses []string, trustedCAPath string, interval time.Durati
}

caCertPool = x509.NewCertPool()
caCertPool.AppendCertsFromPEM(pemCerts)
if !caCertPool.AppendCertsFromPEM(pemCerts) {
return fmt.Errorf("%w: %s", ErrTrustedCAParsing, trustedCAPath)
}
}

var waitBetween time.Duration
Expand Down