From 253be30bd18b1911ce83c4589832327624ef766e Mon Sep 17 00:00:00 2001 From: Justin Santa Barbara Date: Sat, 31 Aug 2013 21:54:23 -0700 Subject: [PATCH] If PKCS1 parsing of the SSH key fails, try PKCS8 --- communicator/ssh/keychain.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/communicator/ssh/keychain.go b/communicator/ssh/keychain.go index 58fd70cbc..686a6b1cb 100644 --- a/communicator/ssh/keychain.go +++ b/communicator/ssh/keychain.go @@ -24,7 +24,12 @@ func (k *SimpleKeychain) AddPEMKey(key string) (err error) { return errors.New("no block in key") } - rsakey, err := x509.ParsePKCS1PrivateKey(block.Bytes) + var rsakey interface{} + rsakey, err = x509.ParsePKCS1PrivateKey(block.Bytes) + if err != nil { + rsakey, err = x509.ParsePKCS8PrivateKey(block.Bytes) + } + if err != nil { return }