eniocarboni / p7m

p7m è uno script per la gestione dei file con firma digitale nel formato CADES
https://quoll.it/firma-digitale-p7m-come-estrarre-il-contenuto/
GNU General Public License v3.0
48 stars 5 forks source link

windows 10 #26

Closed g-i-o-r-g-i-o closed 2 years ago

g-i-o-r-g-i-o commented 2 years ago

Mi sarebbe utile una versione per windows 10... Oppure cortesemente indicatemi un altro script! grazie :-)

eniocarboni commented 2 years ago

@GianniGi p7m è un programma che gira sui sistemi Linux o simili e non c'è per ora una versione per Windows.

Con Windows 10 potresti provare ad installare wsl, il sottosistema per Linux, facendo girare p7m in wsl. L'ho provato velocemente ma direi che almeno la parte non grafica dovrebbe andare senza problemi.

g-i-o-r-g-i-o commented 2 years ago

Ho improvvisato uno script mettendo insieme varie cose trovate durante ricerche avventurose...

import glob
import sys
import os
from OpenSSL import crypto
from OpenSSL._util import (
    ffi as _ffi,
    lib as _lib,
)

# mylist = os.listdir('.')

# os.chdir("/mydir")

for file in glob.glob("*.p7m"):
    print(file)

    with open(file, 'rb') as f:
        p7data = f.read()
    p7 = crypto.load_pkcs7_data(crypto.FILETYPE_ASN1, p7data)

    bio_out = crypto._new_mem_buf()
    res = _lib.PKCS7_verify(p7._pkcs7, _ffi.NULL, _ffi.NULL, _ffi.NULL, bio_out, _lib.PKCS7_NOVERIFY | _lib.PKCS7_NOSIGS)
    if res == 1:
        databytes = crypto._bio_to_string(bio_out)
        # print(databytes)

        filewrite = file + '.pdf'
        with open(filewrite, 'w+b') as f:
            f.write(databytes)

    else:
        errno = _lib.ERR_get_error()
        errstrlib = _ffi.string(_lib.ERR_lib_error_string(errno))
        errstrfunc = _ffi.string(_lib.ERR_func_error_string(errno))
        errstrreason = _ffi.string(_lib.ERR_reason_error_string(errno))
        print(errstrreason)
eniocarboni commented 2 years ago

Bene, non è questo il posto dove fare ipotesi di altri software. Chiuso l'issue dato che non è riferito al programma p7m.