-
Notifications
You must be signed in to change notification settings - Fork 71
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
self-hosting: enabling TLS causes the client to always receive '400 Bad Request' #195
Comments
I encountered the same issue. Here's a snippet of code that resolved it for me. This was my first time working with this codebase, and I didn't have enough time to figure out and follow the existing patterns. This is just a quick fix that worked for me.
I can imagine keeping the env name If anyone could direct me to the proper place for this fix, I'd be more than willing to make it into a PR. Otherwise, I hope it can help someone more familiar with the codebase understand why both of us in this thread have encountered the same problem. :) modified client/auth.go
@@ -29,7 +29,6 @@ func (cc *Client) Auth() (*charm.Auth, error) {
if err != nil {
return nil, charm.ErrAuthFailed{Err: err}
}
- cc.httpScheme = auth.HTTPScheme
p := &jwt.Parser{}
token, _, err := p.ParseUnverified(auth.JWT, &jwt.RegisteredClaims{})
if err != nil {
modified client/client.go
@@ -34,6 +34,7 @@ type Config struct {
KeyType string `env:"CHARM_KEY_TYPE" envDefault:"ed25519"`
DataDir string `env:"CHARM_DATA_DIR" envDefault:""`
IdentityKey string `env:"CHARM_IDENTITY_KEY" envDefault:""`
+ UseTLS bool `env:"CHARM_USE_TLS" envDefault:"false"`
}
// Client is the Charm client.
@@ -110,6 +111,10 @@ func NewClient(cfg *Config) (*Client, error) {
Auth: []ssh.AuthMethod{pkam},
HostKeyCallback: ssh.InsecureIgnoreHostKey(), // nolint
}
+
+ cc.httpScheme = "http"
+ if cfg.UseTLS {
+ cc.httpScheme = "https"
+ }
return cc, nil
} |
I am not sure if this will help anyone else but in my case, I was setting up my own self-hosted charm server with TLS and I was finding that I was also getting
|
I've been trying to setup a self-hosted version of the
charm
service using the package from your APT/DEB repo on an Ubuntu 22.04.1 LTS system (I've tried on both amd64 and arm64 systems).I have a Let's Encrypt-provided TLS certificate, and I've set it up via systemd with these environment variables:
Starting it, I see this in the systemd journal:
I can see that the certificate served up is valid, using certigo:
When I run
charm
from another host, I see this in the server's journal:But back on the other host, I just see
If I change
CHARM_SERVER_USE_TLS
tofalse
and restart the service, then runningcharm
from another host seems to work just fine (I see the menu to Link a machine, Manage linked keys, Set username, Backup or Exit.)What am I doing wrong when I have TLS turned on?
Cheers,
Cos.
The text was updated successfully, but these errors were encountered: