def dump(self): """Serialize the object into a dictionary.""" result = { 'size': self.size, 'filename': self.path, 'changed': self.changed, } if self.backup_file: result['backup_file'] = self.backup_file if self.return_content: content = crypto_utils.load_file_if_exists(self.path, ignore_errors=True) result['dhparams'] = content.decode('utf-8') if content else None return result
def dump(self): """Serialize the object into a dictionary.""" result = { 'filename': self.path, } if self.privatekey_path: result['privatekey_path'] = self.privatekey_path if self.backup_file: result['backup_file'] = self.backup_file if self.return_content: if self.pkcs12_bytes is None: self.pkcs12_bytes = crypto_utils.load_file_if_exists( self.path, ignore_errors=True) result['pkcs12'] = base64.b64encode( self.pkcs12_bytes) if self.pkcs12_bytes else None return result
def dump(self): """Serialize the object into a dictionary.""" result = { 'privatekey': self.privatekey_path, 'filename': self.path, 'format': self.format, 'changed': self.changed, 'fingerprint': self.fingerprint, } if self.backup_file: result['backup_file'] = self.backup_file if self.return_content: if self.publickey_bytes is None: self.publickey_bytes = crypto_utils.load_file_if_exists( self.path, ignore_errors=True) result['publickey'] = self.publickey_bytes.decode( 'utf-8') if self.publickey_bytes else None return result
def dump(self): """Serialize the object into a dictionary.""" result = { 'size': self.size, 'filename': self.path, 'changed': self.changed, 'fingerprint': self.fingerprint, } if self.backup_file: result['backup_file'] = self.backup_file if self.return_content: if self.privatekey_bytes is None: self.privatekey_bytes = crypto_utils.load_file_if_exists(self.path, ignore_errors=True) if self.privatekey_bytes: if crypto_utils.identify_private_key_format(self.privatekey_bytes) == 'raw': result['privatekey'] = base64.b64encode(self.privatekey_bytes) else: result['privatekey'] = self.privatekey_bytes.decode('utf-8') else: result['privatekey'] = None return result