pref: 暂时修改 key fingerprint

pull/9154/head
ibuler 2022-12-02 20:06:56 +08:00
parent fbea1f3480
commit 052a4afef6
2 changed files with 11 additions and 8 deletions

View File

@ -91,6 +91,8 @@ class BaseAccount(JMSOrgBaseModel):
@property
def ssh_key_fingerprint(self):
# Todo: 等待修复
return '等待修复'
if self.public_key:
public_key = self.public_key
elif self.private_key:

View File

@ -165,8 +165,10 @@ def parse_ssh_public_key_str(text: bytes = "", password=None) -> str:
private_key = _parse_ssh_private_key(text, password=password)
if private_key is None:
return ""
public_key_bytes = private_key.public_key().public_bytes(serialization.Encoding.OpenSSH,
serialization.PublicFormat.OpenSSH)
public_key_bytes = private_key.public_key().public_bytes(
serialization.Encoding.OpenSSH,
serialization.PublicFormat.OpenSSH,
)
return public_key_bytes.decode('utf-8')
@ -185,12 +187,11 @@ def _parse_ssh_private_key(text, password=None):
text = text.encode("utf-8")
except UnicodeDecodeError:
return None
if password is not None:
if isinstance(password, str):
try:
password = password.encode("utf-8")
except UnicodeDecodeError:
return None
if isinstance(password, str):
try:
password = password.encode("utf-8")
except UnicodeDecodeError:
return None
try:
private_key = serialization.load_ssh_private_key(text, password=password)