summaryrefslogtreecommitdiff
path: root/paramiko/auth_handler.py
diff options
context:
space:
mode:
authorPaul Kapp <paullkapp+radssh@gmail.com>2017-08-22 06:31:47 -0400
committerPaul Kapp <paullkapp+radssh@gmail.com>2017-08-22 06:31:47 -0400
commit7229597ce0925ee8dafe97544f42dcc193fbad8f (patch)
treed0578884ddc4d79aad3699298600dd5fd8d0fd83 /paramiko/auth_handler.py
parent08f503740182608570ac87661225fe2e11914d8f (diff)
downloadparamiko-7229597ce0925ee8dafe97544f42dcc193fbad8f.tar.gz
Generic certificate support
Roll agnostic certificate support into PKey, and tweak publickey authentication to use it only if set. Requires explicit call to PKey.load_certificate() in order to alter the authentication behavior.
Diffstat (limited to 'paramiko/auth_handler.py')
-rw-r--r--paramiko/auth_handler.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/paramiko/auth_handler.py b/paramiko/auth_handler.py
index ae88179e..0b13722c 100644
--- a/paramiko/auth_handler.py
+++ b/paramiko/auth_handler.py
@@ -186,8 +186,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):
@@ -244,8 +249,13 @@ 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)