Skip to content

Commit

Permalink
shared/cliconfig: Fix static analysis
Browse files Browse the repository at this point in the history
Signed-off-by: Stéphane Graber <[email protected]>
  • Loading branch information
stgraber committed Feb 11, 2024
1 parent 4577279 commit 976e14e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions shared/cliconfig/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,16 +325,16 @@ func (c *Config) getConnectionArgs(name string) (*incus.ConnectionArgs, error) {
return nil, err
}

ecdsaKey, _ := (sshKey).(*ecdsa.PrivateKey)
rsaKey, _ := (sshKey).(*rsa.PrivateKey)
if ecdsaKey != nil {
ecdsaKey, okEcdsa := (sshKey).(*ecdsa.PrivateKey)
rsaKey, okRsa := (sshKey).(*rsa.PrivateKey)
if okEcdsa {
derKey, err := x509.MarshalECPrivateKey(ecdsaKey)
if err != nil {
return nil, err
}

content = pem.EncodeToMemory(&pem.Block{Type: "PRIVATE KEY", Bytes: derKey})
} else if rsaKey != nil {
} else if okRsa {
derKey := x509.MarshalPKCS1PrivateKey(rsaKey)
content = pem.EncodeToMemory(&pem.Block{Type: "PRIVATE KEY", Bytes: derKey})
} else {
Expand Down

0 comments on commit 976e14e

Please sign in to comment.