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

tsh: Fix redundant error in PPK generation on relogin #23899

Merged
merged 4 commits into from
Apr 3, 2023
Merged
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
12 changes: 7 additions & 5 deletions lib/client/keystore.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,17 +160,19 @@ func (fs *FSKeyStore) AddKey(key *Key) error {
if err := fs.writeBytes(key.TLSCert, fs.tlsCertPath(key.KeyIndex)); err != nil {
return trace.Wrap(err)
}

// We only generate PPK files for use by PuTTY when running tsh on Windows.
if runtime.GOOS == constants.WindowsOS {
ppkFile, err := key.PPKFile()
if err == nil {
// PPKFile can only be generated from an RSA private key. If the key is in a different
// format, a BadParameter error is returned and we can skip PPK generation.
if err != nil && !trace.IsBadParameter(err) {
fs.log.Debugf("Cannot convert private key to PPK-formatted keypair: %v", err)
} else {
if err := fs.writeBytes(ppkFile, fs.ppkFilePath(key.KeyIndex)); err != nil {
return trace.Wrap(err)
}
} else if !trace.IsBadParameter(err) {
return trace.Wrap(err)
}
// PPKFile can only be generated from an RSA private key.
fs.log.WithError(err).Debugf("Cannot convert private key to PPK-formatted keypair.")
}

// Store per-cluster key data.
Expand Down