Détails du package
smp-licence-encrypt-sample
Revenir à la liste des packages
Fichier control :
package : smp-licence-encrypt-sample
version : 5
architecture : all
section : base
priority : optional
name :
categories :
maintainer : Simon Fonteneau
description : Exemple de paquet avec un text chiffrer par le certificat du poste puis déchiffré par la clé privé du poste
depends :
conflicts :
maturity :
locale :
target_os :
min_os_version :
max_os_version :
min_wapt_version : 1.5
sources :
installed_size :
impacted_process :
description_fr :
description_pl :
description_de :
description_es :
description_pt :
description_it :
description_nl :
description_ru :
audit_schedule :
editor :
keywords :
licence :
homepage :
package_uuid : d2464bce-7123-4bfa-ba8c-183fa07fb84e
valid_from :
valid_until :
forced_install_on :
changelog :
signer : wapt.lesfourmisduweb.org
signer_fingerprint: 1e54425be03a2a3ea1a264b40d984c31f17a6a489a3b722acb993cbf6561e903
signature : NRbRcJCneeggJrdnCp+yYkdmWTaQ3niWGUa48pXX5akqYSvJ+ucrF8WjhOIOMuqvSPPIkooqpjBtPh3ZzJZvHQ6pvpFoupFnJI8W1MnPQzQ/tCnkg9uMhl+vbi4vkhsoLSrtL24pUw2EUFvFLvtTW++zHbHlOd/KN4uFljy3wxOv6CWAbaTz/VFzH/Xi54NvzDye4YmOUHOjqaAdOxGuH2Q6hplqPaX4ZsgVc+VrKhnOU6Sl+N3dPEmUWXUgZIYZ8lz8TXPWsOanp9SMmxWvgRndjBDzAZyhuLHyl2YiqO3LtPWeUaSadd8ZPFhzlctxs7uaZ2BIHPeIsgnnqyiN5g==
signature_date : 2020-07-04T01:45:07.081000
signed_attributes : package,version,architecture,section,priority,name,categories,maintainer,description,depends,conflicts,maturity,locale,target_os,min_os_version,max_os_version,min_wapt_version,sources,installed_size,impacted_process,description_fr,description_pl,description_de,description_es,description_pt,description_it,description_nl,description_ru,audit_schedule,editor,keywords,licence,homepage,package_uuid,valid_from,valid_until,forced_install_on,changelog,signer,signer_fingerprint,signature_date,signed_attributes
Fichier setup.py :
# -*- coding: utf-8 -*-
from setuphelpers import *
import json
from waptcrypto import SSLCertificate
import waptguihelper
uninstallkey = []
def install():
encryptlist = json.loads(open('encrypt-txt.json','r').read())
if WAPT.host_uuid in encryptlist:
host_key = WAPT.get_host_key()
encrypttxt = host_key.decrypt(encryptlist[WAPT.host_uuid].decode('base64')).decode('utf-8')
print( r'Voici le text dechiffrer : %s' % encrypttxt)
else:
error('%s not found in encrypt-txt.json' % WAPT.host_uuid)
def update_package():
urlserver = inifile_readstring(makepath(install_location('WAPT_is1'),'wapt-get.ini'),'global','wapt_server').replace('https://','')
encrypttxt = str(raw_input('Entrez le text a chiffrer :').encode('utf-8'))
encryptlist = {}
credentials_url = waptguihelper.login_password_dialog('Credentials for wapt server',urlserver,'admin','')
data = json.loads(wgets('https://%s:%s@%s/api/v1/hosts?columns=host_certificate&limit=10000' % (credentials_url['user'],credentials_url['password'],urlserver)))
for value in data['result']:
if value['host_certificate']:
host_cert=SSLCertificate(crt_string=value['host_certificate'])
encryptlist[value['uuid']]=host_cert.encrypt(encrypttxt).encode('base64')
print(value['computer_fqdn'] + ' : ' + value['uuid'] + ' : ' + encryptlist[value['uuid']])
open('encrypt-txt.json','w').write(json.dumps(encryptlist))
if __name__ == '__main__':
update_package()