mirror of
https://github.com/D-Modem/bbs.git
synced 2026-11-28 17:38:04 -08:00
23 lines
473 B
Go
23 lines
473 B
Go
package timesync
|
|
|
|
import (
|
|
"crypto/tls"
|
|
"crypto/x509"
|
|
"errors"
|
|
"os"
|
|
)
|
|
|
|
// RootCAs is a client TLS configuration that trusts the certificates in a
|
|
// PEM file (a private NTS-KE server's) alone.
|
|
func RootCAs(file string) (*tls.Config, error) {
|
|
b, err := os.ReadFile(file)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
pool := x509.NewCertPool()
|
|
if !pool.AppendCertsFromPEM(b) {
|
|
return nil, errors.New(file + ": no certificates")
|
|
}
|
|
return &tls.Config{RootCAs: pool}, nil
|
|
}
|