summaryrefslogtreecommitdiff
path: root/paramiko/auth_handler.py
diff options
context:
space:
mode:
authorJeff Forcier <jeff@bitprophet.org>2017-09-05 17:41:33 -0700
committerJeff Forcier <jeff@bitprophet.org>2017-09-05 17:41:33 -0700
commitcf012007eb793954a09662935c06c8858381cd3c (patch)
tree9cdcc70713738f665bf2efdb2989891f2ea32ecd /paramiko/auth_handler.py
parentbd807adfa5b8bee01fe30eee5c7c5247aa3fd530 (diff)
parent898152cf049daf1a861206b95b39679b032803d6 (diff)
downloadparamiko-cf012007eb793954a09662935c06c8858381cd3c.tar.gz
Merge branch 'master' into 1013-int
Diffstat (limited to 'paramiko/auth_handler.py')
-rw-r--r--paramiko/auth_handler.py26
1 files changed, 18 insertions, 8 deletions
diff --git a/paramiko/auth_handler.py b/paramiko/auth_handler.py
index e229df8d..6b66e0e0 100644
--- a/paramiko/auth_handler.py
+++ b/paramiko/auth_handler.py
@@ -187,8 +187,13 @@ class AuthHandler (object):
m.add_string(service)
m.add_string('publickey')
m.add_boolean(True)
- m.add_string(key.get_name())
- m.add_string(key)
+ # Use certificate contents, if available, plain pubkey otherwise
+ if key.public_blob:
+ m.add_string(key.public_blob.key_type)
+ m.add_string(key.public_blob.key_blob)
+ else:
+ m.add_string(key.get_name())
+ m.add_string(key)
return m.asbytes()
def wait_for_response(self, event):
@@ -252,8 +257,14 @@ class AuthHandler (object):
m.add_string(password)
elif self.auth_method == 'publickey':
m.add_boolean(True)
- m.add_string(self.private_key.get_name())
- m.add_string(self.private_key)
+ # Use certificate contents, if available, plain pubkey
+ # otherwise
+ if self.private_key.public_blob:
+ m.add_string(self.private_key.public_blob.key_type)
+ m.add_string(self.private_key.public_blob.key_blob)
+ else:
+ m.add_string(self.private_key.get_name())
+ m.add_string(self.private_key)
blob = self._get_session_blob(
self.private_key, 'ssh-connection', self.username)
sig = self.private_key.sign_ssh_data(blob)
@@ -456,10 +467,9 @@ class AuthHandler (object):
INFO,
'Auth rejected: public key: %s' % str(e))
key = None
- except:
- self.transport._log(
- INFO,
- 'Auth rejected: unsupported or mangled public key')
+ except Exception as e:
+ msg = 'Auth rejected: unsupported or mangled public key ({0}: {1})' # noqa
+ self.transport._log(INFO, msg.format(e.__class__.__name__, e))
key = None
if key is None:
self._disconnect_no_more_auth()