fix: SSH key double-base64 encoding — PEM was corrupted during storage
All checks were successful
Build & Sign Wraith / Build Windows + Sign (push) Successful in 1m3s
All checks were successful
Build & Sign Wraith / Build Windows + Sign (push) Successful in 1m3s
Root cause: frontend btoa() encoded the PEM before sending to Go []byte parameter. Wails already base64-encodes []byte over JSON bridge, so the vault stored base64(base64(pem)) — garbage. Fix: Go method now accepts string, frontend sends raw PEM. Keys must be re-added after this update. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
163af456b4
commit
901d9c257d
@ -447,14 +447,12 @@ async function saveNewCredential(): Promise<void> {
|
|||||||
"", // domain — not collected in this form
|
"", // domain — not collected in this form
|
||||||
) as Credential;
|
) as Credential;
|
||||||
} else {
|
} else {
|
||||||
// SSH Key: CreateSSHKeyCredential(name, username string, privateKeyPEM []byte, passphrase string)
|
// SSH Key: CreateSSHKeyCredential(name, username, privateKeyPEM string, passphrase string)
|
||||||
// Wails serialises []byte as base64. We encode the raw PEM string with btoa().
|
|
||||||
const pemBase64 = btoa(newCred.value.privateKeyPEM.trim());
|
|
||||||
created = await Call.ByName(
|
created = await Call.ByName(
|
||||||
`${APP}.CreateSSHKeyCredential`,
|
`${APP}.CreateSSHKeyCredential`,
|
||||||
newCred.value.name.trim(),
|
newCred.value.name.trim(),
|
||||||
newCred.value.username.trim(),
|
newCred.value.username.trim(),
|
||||||
pemBase64,
|
newCred.value.privateKeyPEM.trim(),
|
||||||
newCred.value.passphrase,
|
newCred.value.passphrase,
|
||||||
) as Credential;
|
) as Credential;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -490,13 +490,12 @@ func (a *WraithApp) CreatePassword(name, username, password, domain string) (*cr
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CreateSSHKeyCredential imports an SSH private key and creates a Credential
|
// CreateSSHKeyCredential imports an SSH private key and creates a Credential
|
||||||
// record referencing it. privateKeyPEM is the raw PEM bytes (Wails serialises
|
// record referencing it. privateKeyPEM is the raw PEM string (NOT base64 encoded).
|
||||||
// []byte as base64 over the JSON bridge, so the frontend passes btoa(pem)).
|
func (a *WraithApp) CreateSSHKeyCredential(name, username string, privateKeyPEM string, passphrase string) (*credentials.Credential, error) {
|
||||||
func (a *WraithApp) CreateSSHKeyCredential(name, username string, privateKeyPEM []byte, passphrase string) (*credentials.Credential, error) {
|
|
||||||
if a.Credentials == nil {
|
if a.Credentials == nil {
|
||||||
return nil, fmt.Errorf("vault is locked")
|
return nil, fmt.Errorf("vault is locked")
|
||||||
}
|
}
|
||||||
return a.Credentials.CreateSSHKeyCredential(name, username, privateKeyPEM, passphrase)
|
return a.Credentials.CreateSSHKeyCredential(name, username, []byte(privateKeyPEM), passphrase)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteCredential removes a credential by ID.
|
// DeleteCredential removes a credential by ID.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user