def export(self, format='RFC4716'): pubkey = pubkey_parse(self.key) f = format.upper() if f == 'RFC4716': return pubkey.format_rfc4716() if f == 'PEM': return pubkey.format_pem() raise ValueError("Invalid format")
def clean(self): try: pubkey = pubkey_parse(self.key) except PublicKeyParseError as e: raise ValidationError(str(e)) self.key = pubkey.format_openssh() self.fingerprint = pubkey.fingerprint() if not self.name: if not pubkey.comment: raise ValidationError('Name or key comment required') self.name = pubkey.comment
def setUpClass(cls): super(FingerprintTestCase, cls).setUpClass() cls.key_path = os.path.join(cls.key_dir, 'key1') cls.pubkey_path = cls.key_path + '.pub' ssh_keygen(comment='comment', file=cls.key_path) cls.pubkey = util.pubkey_parse(read_pubkey(cls.key_path + '.pub'))