Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lxc: Use TrustToken field if supported by the server #14457

Closed
wants to merge 1 commit into from
Closed
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
8 changes: 8 additions & 0 deletions lxc/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,19 @@ func (c *cmdRemoteAdd) addRemoteFromToken(addr string, server string, token stri
}
}

// Implicitly runs GetServer which updates the servers extensions.
d, err := conf.GetInstanceServer(server)
if err != nil {
return api.StatusErrorf(http.StatusServiceUnavailable, "%s: %w", i18n.G("Unavailable remote server"), err)
}

req := api.CertificatesPost{}
if d.HasExtension("explicit_trust_token") {
req.TrustToken = token
} else {
req.Password = token
}

// Add client certificate to trust store. Even if we are already trusted (src.Auth == "trusted"),
// we want to send the token to invalidate it. Therefore, we can ignore the conflict error, which
// is thrown if we are trying to add a client cert that is already trusted by LXD remote.
Expand Down
Loading