sftp: skip Ed25519Key if missing (#32655)

This commit is contained in:
Benjamin Dauvergne 2019-04-29 17:17:34 +02:00
parent a66c64273a
commit f065c32f76
1 changed files with 6 additions and 1 deletions

View File

@ -31,7 +31,10 @@ from django.utils.encoding import force_bytes
import paramiko
from paramiko.dsskey import DSSKey
from paramiko.ecdsakey import ECDSAKey
from paramiko.ed25519key import Ed25519Key
try:
from paramiko.ed25519key import Ed25519Key
except ImportError:
Ed25519Key = None
from paramiko.rsakey import RSAKey
@ -39,6 +42,8 @@ def _load_private_key(content_or_file, password=None):
if not hasattr(content_or_file, 'read'):
content_or_file = io.BytesIO(force_bytes(content_or_file))
for pkey_class in RSAKey, DSSKey, Ed25519Key, ECDSAKey:
if pkey_class is None:
continue
try:
return pkey_class.from_private_key(
content_or_file,