ATTENTION CE DÉPÔT n'est plus compatible 1.3 vous devez migrer en 1.5.1.21 !
Fichier control :
package : smp-licence-encrypt-sample version : 4 architecture : all section : base priority : optional 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 : audit_schedule : signer : wapt.lesfourmisduweb.org signer_fingerprint: 8da83ebdac1a25e820b186510d049f47407b11835b0664fdc5bacd3595b1671d signature : bHHdr8u5SZag/ILlLMxARGjuB47vCEa30LN/ncbO8jBIHy6sVvgkBPcb9ei5zfWc/zeFaxIzUqrznjaAn4/gAJl7EroBKkXfOVdEzeDIbU7Xe+FQPCoCuty6YEtfZ12NTxPGyUZ0PW7O5srfM0irb4E6Q7lmbTD/3CwXVajyC7z2zVokKLkNt7UTAHawTFns1M+a3BxGLn110OZ8mfcIqOzQ0Nt93fEkl6nkJPmU8YW0rn4ZSszQqPZneE4SpheO0/vkgnLBtzu9Wii9zupEQeRTm9ohEiPGVyR/7RMpFGnyzl430wsIjmGQeEBuxsmS10vghacQ38tHmOYjVaZsaA== signature_date : 20180605-221244 signed_attributes : package,version,architecture,section,priority,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,audit_schedule,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( ur'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()