windows client connect failed because connect.go:171: wgtypes: failed to parse base64-encoded key: illegal base64 data at input byte 8 #507

Closed
opened 2025-11-20 05:12:41 -05:00 by saavagebueno · 2 comments
Owner

Originally created by @fage520 on GitHub (Nov 13, 2023).

Describe the problem
I created a Setup Key (value: DFA5BE66-8C79-4019-9CE6-720B09F0E632), configured it on the Windows client (version 0.24.2), and then tried to connect. However, the connection failed.
I checked the logs and it prompted: ERRO client/internal/connect.go:171: wgtypes: failed to parse base64-encoded key: illegal base64 data at input byte 8.
However, the above issue did not appear on the Linux client. (Command: netbird up --setup-key DFA5BE66-8C79-4019-9CE6-720B09F0E632).
I checked the source code and found that there was an error in the logic, which caused the "illegal base64 data at input byte 8" error when running on both Windows and Linux.

The exception code is as follows:
import "encoding/base64"
import log "github.com/sirupsen/logrus"

func main() {
var s = "DFA5BE66-8C79-4019-9CE6-720B09F0E632"
decodeString, err := base64.StdEncoding.DecodeString(s)
if err != nil {
log.Error(err)
}
println(decodeString)
}

To Reproduce
Steps to reproduce the behavior:

  1. created a Setup Key
  2. configured it on the Windows client
  3. tried to connect
  4. See log

Expected behavior
A clear and concise description of what you expected to happen.

NetBird status -d output:
If applicable, add the output of the netbird status -d command

Screenshots

1699882281815

Additional context
Add any other context about the problem here.

Originally created by @fage520 on GitHub (Nov 13, 2023). **Describe the problem** I created a Setup Key (value: DFA5BE66-8C79-4019-9CE6-720B09F0E632), configured it on the Windows client (version 0.24.2), and then tried to connect. However, the connection failed. I checked the logs and it prompted: ERRO client/internal/connect.go:171: wgtypes: failed to parse base64-encoded key: illegal base64 data at input byte 8. However, the above issue did not appear on the Linux client. (Command: netbird up --setup-key DFA5BE66-8C79-4019-9CE6-720B09F0E632). I checked the source code and found that there was an error in the logic, which caused the "illegal base64 data at input byte 8" error when running on both Windows and Linux. The exception code is as follows: import "encoding/base64" import log "github.com/sirupsen/logrus" func main() { var s = "DFA5BE66-8C79-4019-9CE6-720B09F0E632" decodeString, err := base64.StdEncoding.DecodeString(s) if err != nil { log.Error(err) } println(decodeString) } **To Reproduce** Steps to reproduce the behavior: 1. created a Setup Key 2. configured it on the Windows client 3. tried to connect 4. See log **Expected behavior** A clear and concise description of what you expected to happen. **NetBird status -d output:** If applicable, add the output of the `netbird status -d` command **Screenshots** ![1699882281815](https://github.com/netbirdio/netbird/assets/58712266/92e72467-7ce9-4cd0-89d0-94008938f25f) **Additional context** Add any other context about the problem here.
Author
Owner

@surik commented on GitHub (Nov 14, 2023):

Hi @fage520, indeed the SetupKeys are not base64 encoded by design.

The error you see

ERRO client/internal/connect.go:171: wgtypes: failed to parse base64-encoded key: illegal base64 data at input byte 8.

is more likely related to your PreSharedKey from the config(C:\ProgramData\Netbird\config.json on Windows).

See the output of netbird --help:

  -p, --preshared-key string    Sets Wireguard PreSharedKey property. If set, then only peers that have the same key can communicate.

Could it be that by any chance to set that value on the Windows machine? You can check that in your config.json.

@surik commented on GitHub (Nov 14, 2023): Hi @fage520, indeed the SetupKeys are not base64 encoded by design. The error you see ``` ERRO client/internal/connect.go:171: wgtypes: failed to parse base64-encoded key: illegal base64 data at input byte 8. ``` is more likely related to your `PreSharedKey` from the config(`C:\ProgramData\Netbird\config.json` on Windows). See the output of `netbird --help`: ``` -p, --preshared-key string Sets Wireguard PreSharedKey property. If set, then only peers that have the same key can communicate. ``` Could it be that by any chance to set that value on the Windows machine? You can check that in your config.json.
Author
Owner

@fage520 commented on GitHub (Nov 14, 2023):

Hi @fage520, indeed the SetupKeys are not base64 encoded by design.

The error you see

ERRO client/internal/connect.go:171: wgtypes: failed to parse base64-encoded key: illegal base64 data at input byte 8.

is more likely related to your PreSharedKey from the config(C:\ProgramData\Netbird\config.json on Windows).

See the output of netbird --help:

  -p, --preshared-key string    Sets Wireguard PreSharedKey property. If set, then only peers that have the same key can communicate.

Could it be that by any chance to set that value on the Windows machine? You can check that in your config.json.

Thank you, it was indeed my configuration mistake. I misunderstood the purpose of the PreSharedKey.

@fage520 commented on GitHub (Nov 14, 2023): > Hi @fage520, indeed the SetupKeys are not base64 encoded by design. > > The error you see > > ``` > ERRO client/internal/connect.go:171: wgtypes: failed to parse base64-encoded key: illegal base64 data at input byte 8. > ``` > > is more likely related to your `PreSharedKey` from the config(`C:\ProgramData\Netbird\config.json` on Windows). > > See the output of `netbird --help`: > > ``` > -p, --preshared-key string Sets Wireguard PreSharedKey property. If set, then only peers that have the same key can communicate. > ``` > > Could it be that by any chance to set that value on the Windows machine? You can check that in your config.json. Thank you, it was indeed my configuration mistake. I misunderstood the purpose of the PreSharedKey.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: SVI/netbird#507