mirror of
https://github.com/juanfont/headscale.git
synced 2024-11-29 18:33:05 +00:00
remove private key constant errors from NewHeadscale
This commit is contained in:
parent
21f0e089b6
commit
0e405c7ce0
1 changed files with 3 additions and 9 deletions
12
app.go
12
app.go
|
@ -51,12 +51,6 @@ const (
|
||||||
errUnsupportedLetsEncryptChallengeType = Error(
|
errUnsupportedLetsEncryptChallengeType = Error(
|
||||||
"unknown value for Lets Encrypt challenge type",
|
"unknown value for Lets Encrypt challenge type",
|
||||||
)
|
)
|
||||||
|
|
||||||
ErrFailedPrivateKey = Error("failed to read or create private key")
|
|
||||||
ErrFailedNoisePrivateKey = Error(
|
|
||||||
"failed to read or create Noise protocol private key",
|
|
||||||
)
|
|
||||||
ErrSamePrivateKeys = Error("private key and noise private key are the same")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -131,17 +125,17 @@ func LookupTLSClientAuthMode(mode string) (tls.ClientAuthType, bool) {
|
||||||
func NewHeadscale(cfg *Config) (*Headscale, error) {
|
func NewHeadscale(cfg *Config) (*Headscale, error) {
|
||||||
privateKey, err := readOrCreatePrivateKey(cfg.PrivateKeyPath)
|
privateKey, err := readOrCreatePrivateKey(cfg.PrivateKeyPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, ErrFailedPrivateKey
|
return nil, fmt.Errorf("failed to read or create private key: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TS2021 requires to have a different key from the legacy protocol.
|
// TS2021 requires to have a different key from the legacy protocol.
|
||||||
noisePrivateKey, err := readOrCreatePrivateKey(cfg.NoisePrivateKeyPath)
|
noisePrivateKey, err := readOrCreatePrivateKey(cfg.NoisePrivateKeyPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, ErrFailedNoisePrivateKey
|
return nil, fmt.Errorf("failed to read or create Noise protocol private key: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if privateKey.Equal(*noisePrivateKey) {
|
if privateKey.Equal(*noisePrivateKey) {
|
||||||
return nil, ErrSamePrivateKeys
|
return nil, fmt.Errorf("private key and noise private key are the same: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var dbString string
|
var dbString string
|
||||||
|
|
Loading…
Reference in a new issue