1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

3923 validate key format

This commit is contained in:
kobayashi
2020-01-18 21:52:42 -05:00
parent 606f3dacbb
commit c6d18da2eb
5 changed files with 52 additions and 0 deletions

View File

@@ -16,6 +16,8 @@ def validate_rsa_key(key, is_secret=True):
"""
Validate the format and type of an RSA key.
"""
if key.startswith('ssh-rsa '):
raise forms.ValidationError("OpenSSH line format is not supported. Please ensure that your public is in PEM (base64) format.")
try:
key = RSA.importKey(key)
except ValueError: