ONYX - Utilisation - Signature électronique de PDFs/en

Différence entre versions

De MappingDoc
(Page créée avec « The CSR are in general created in the PEM format encoded in Base64. You can open it in a simple text editor. »)
(Page créée avec « It is also possible to have the certificate and the private key in separate files or within the same file. »)
Ligne 62 : Ligne 62 :
 
The CSR are in general created in the PEM format encoded in Base64. You can open it in a simple text editor.
 
The CSR are in general created in the PEM format encoded in Base64. You can open it in a simple text editor.
  
Il est possible d'avoir le certificat et la clé privée dans des fichiers séparés ou bien dans le même fichier
+
It is also possible to have the certificate and the private key in separate files or within the same file.
  
 
=====Dans des fichiers séparés=====
 
=====Dans des fichiers séparés=====

Version du 5 mai 2020 à 13:24

Autres langues :
English • ‎français

Introduction

Mapping gives you the possibility to numerically sign the PDF files generated. To do so, electronic signatures associated with private keys are used.

prerequisite

Prior to this, we need to have in possession a certificate and a private key.

Generation of a certifiate and a private key. (For our example, via openssl)

openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout private.pem -out certificate.cer

Private key : private.pem
Certificate : certificate.cer

This command will generate a certificate and a private key named "autogenerated" without having to use an Certification authority. This makes sens only for testing purposes. For a real usage, we will need to obtain a certificate from the Certification Authority (CA)

Limits

The certificate is easily visible on Foxit Reader but not on Acrobat Reader.

To be done

  1. Check if the certificate is visible on Acrobat when issued by a CA
  2. Validate the PFX
  3. Documenting the timestampurl (Probably a bug on it)

Remarks on certificates

Different types of certificates

MAPPING handles different types of certificates

PFX

A PFX file (or PKCS#12) is a file containing at the same time a private key and a certificate X.509. The generation of the request of the certificate signature (CSR, Certificate Signing Request) remains a recurrent problem for the customers. With a PFX file, the customer is no longuer required to create its own CSR. A Certification authority will do it in a totally secured way during the Request for Certificate process.

CSR

The Certification Authority (AC) uses the data of the request of the certificate signature to create your SSL certificate. Here is a list of the jey information :

Information about your company and the website that you want to secure via the SSL certificate. This one contains :

Label Description
Common Name (CN)(ex : *.example.fr www.example.fr mail.example.fr) The fully domain name qualified of your server. (FQDN)
Organization (O) The social denomisation of your company. Make sure not to use abbreviation and include the company structure (Such as SA or other). For the EV and OV SSL, those information will be verified by the AC and be included in the certificate.
Organizational Unit (OU) Organization department in charge of certificates management
City/Locality (L) Town where your company is located.Please enter the full name.
State/County/Region (S) Region where your company is located.Please enter the full name.
Country (C) 2 letter code of the country where your company is located.
Email Address Contact person email address of your company.

2. Public key included in the certificate. The SSL uses the public key cryptography or asymetric to encode the exchanged data during a SSL connection. The public key is used for the encoding and the its private key used to decode the data.

3. Information on the type and length of the key. The length of the most common key is RSA 2048 but some Autority of Certification (AC) accept longeur keys (Ex : RSA 4096+) and the ECC keys.


The CSR are in general created in the PEM format encoded in Base64. You can open it in a simple text editor.

It is also possible to have the certificate and the private key in separate files or within the same file.

Dans des fichiers séparés

Voici un exemple d'un certificat et une clé privée dans deux fichiers séparés

Fichier private.pem

-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFA
...
HRgFVVNXS8jTjAo2LL7U6rZK8gwsXWzqaXNLsvwj9HoF89+reRosTfIIk
-----END PRIVATE KEY-----


Fichier certificate.cer

-----BEGIN CERTIFICATE-----
MIID2TCCAsGgAwIBAgIJAKcd3Qk2E
...
bJVSEN4kV0mdg5jrFhCCZjrlumzs+MQ=
-----END CERTIFICATE-----

Dans le même fichier

Voici un exemple d'un certificat et d'une clé privée définis dans le même fichier certifcle.pem

Fichier certifcle.pem

Son contenu est une simple concaténation du contenu du fichier clé privé et du certificat.

-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFA
...
HRgFVVNXS8jTjAo2LL7U6rZK8gwsXWzqaXNLsvwj9HoF89+reRosTfIIk
-----END PRIVATE KEY-----
-----BEGIN CERTIFICATE-----
MIID2TCCAsGgAwIBAgIJAKcd3Qk2E
...
bJVSEN4kV0mdg5jrFhCCZjrlumzs+MQ=
-----END CERTIFICATE-----

Paramétrage

L'utilisation de la signature électronique au sein de MAPPING nécessite la copie de la clé privé et du certificat sur le serveur.
Son utilisation est alors possible dans les workflows MAPPING ou bien en ligne de commande via la commande map_xps

Copie des fichiers sur le serveur

Il faut mettre le fichier de la clé privé et le fichier du certificat sur le système de fichier de serveur

(Exemple : /apps/mapping/certificate)

Les différents paramètres

La signature électronique requiert l'utilisation de plusieurs paramètres. Vous trouverez la liste dans le tableau ci-dessous :

Nom du paramètre valeur Signification
signclass < 3 -
signdriver VIDE Signature électronique désactivée (les autres paramètres n'auront alors pas d'effet)
OPENSSL Le mode OPENSSL est compatible avec toutes les plateformes supportées par Mapping. Il utilise un ou deux fichiers contenant les clés publiques et privées. Les fichiers doivent se trouver sur le serveur Mapping (chemins réseaux non supportés).
FIRSTSIGNATURE Le mode FIRSTSIGNATURE est valable uniquement sous Windows car il utilise un certificat installé sur le poste. Le certificat utilisé est le premier de la liste des certificats affichés dans Internet Explorer.
WINDOWS Activation du mode SHA1. Ceci est valable uniquement sous Windows car il utilise un certificat installé sur le poste. Le certificat utilisé est le défini par sa clé de hashage (empreinte numérique).
signmode FILENAME A utiliser pour les signatures électroniques activées en mode OPENSSL
signpassword Valeur de la passphrase du certificat Utilisé dans le cas où le certificat contient une passphrase de sécurité
signsha1hash Valeur du SHA1 utilisé si le paramètre signdriver est renseigné avec la valeur "WINDOWS"
signpemfile Chemin complet du fichier de clé privé Fichier de clé privée seul s'il est séparé du certificat ou fichier contenant à la fois la clé privée et le certificat
signcerfile Chemin complet du fichier de certificat Utilisé uniquement si le fichier du certificat est séparé du fichier de clé privée
signpfxfile Chemin complet du fichier PFX Utilisé uniquement pour les fichiers PFX (PKCS#12)
timestampurl ?? A documenter

Utilisation

Workflow

La boite des workflows MAPPING à utilisée est la boite toPDF. (XPS to web format / toPDF) De base, cette boite permet de générer un PDF à partir d'un fichier XPS. Cependant il est possible d'y paramétrer une signature électronique.

Onglet Signature


OX S SIGNPDF1.jpg

Cet onglet permet l'initialisation des paramètres listés dans le tableau des paramètres.

remarque : A noté que le workflow initialise le paramètre signclass à la valeur 0.

map_xps

Il est également possible d'utiliser la commande MAPPING de conversion map_xps

Il faudra alors initialiser les paramètres de signature électronique via des paramètres -param:CLE=VALEUR

Exemple :

"/apps/mapping/bin/map_xps" "-infile:/apps/mapping/infile/infile.xps" "-param:signmode=FILENAME" "-param:signclass=0"
-param:signdriver=OPENSSL" "-param:signpemfile=/apps/mapping/certificate/private.pem"
"-param:signcerfile=/apps/mapping/certificate/certificate.cer" "-toPDF" "-outfile:/apps/mapping/out/out.pdf"

Exemples

Exemple 1

Dans cette exemple, nous allons voir comment convertir le fichier d'entrée (fichier XPS) en PDF en lui appliquant un certificat. Nous allons voir comment faire cela à travers d'un workflow et comment faire la même chose en ligne de commande.

Workflows

Création du worflow suivant :

OX S SIGNPDF2.jpg

Détail de la boite toPDF (Onglet standard) :

OX S SIGNPDF3.jpg

Détail de la boite toPDF (Onglet Signature) :

OX S SIGNPDF4.jpg

Ligne de commande sans profil de conversion

Exécutez la commande suivante :

"/apps/mapping/bin/map_xps" "-infile:/apps/mapping/infile/infile.xps" "-param:signclass=0" "-param:signmode=FILENAME" 
"-param:signdriver=OPENSSL" "-param:signpemfile=/apps/mapping/infile/private.pem" 
"-param:signcerfile=/apps/mapping/infile/certificate.cer" "-toPDF" "-outfile:/apps/mapping/output/out.pdf"

Ligne de commande avec profil de conversion

Profil de conversion utilisé :

<pdf_signature>
   <label>for Adobe Reader</label>
   <language>PDF</language>
   <signclass>0</signclass>
   <signmode>FILENAME</signmode>
   <signpassword></signpassword>
   <signdriver>OPENSSL</signdriver>
   <signpfxfile></signpfxfile>
   <signpemfile>apps/mapping/infile/private.pem</signpemfile>
   <signcerfile>apps/mapping/infile/certificate.cer</signcerfile>
 </pdf_signature>

Exécuter la commande suivante :

"/apps/mapping/bin/map_xps" "-infile:/apps/mapping/infile/infile.xps" "-toPDF" "-outfile:/apps/mapping/output/out.pdf"
"-profile:pdf_signature"

Exemple 2

Dans cette exemple, nous allons voir comment utiliser un fichier contenant la clé privée et le certificat

Workflows

Création du worflow suivant :

OX S SIGNPDF2.jpg


Détail de la boite toPDF (Onglet standard) :

OX S SIGNPDF3.jpg


Détail de la boite toPDF (Onglet Signature) :

Le fichier ayant la clé privée et le certificat doit être mis dans le paramètre pem.


OX S SIGNPDF5.jpg


Ligne de commande sans profil de conversion

Exécutez la commande suivante :

"/apps/mapping/bin/map_xps" "-infile:/apps/mapping/infile/infile.xps" "-param:signclass=0" "-param:signmode=FILENAME" 
"-param:signdriver=OPENSSL" "-param:signpemfile=/apps/mapping/infile/privatekey_certificate.pem" "-toPDF"
"-outfile:/apps/mapping/output/out.pdf"

Ligne de commande avec profil de conversion

Profil de conversion utilisé :

<pdf_signature>
   <label>for Adobe Reader</label>
   <language>PDF</language>
   <signclass>0</signclass>
   <signmode>FILENAME</signmode>
   <signpassword></signpassword>
   <signdriver>OPENSSL</signdriver>
   <signpfxfile></signpfxfile>
   <signpemfile>apps/mapping/infile/privatekey_certificate.pem</signpemfile>
   <signcerfile></signcerfile>
 </pdf_signature>


Exécuter la commande suivante :

"/apps/mapping/bin/map_xps" "-infile:/apps/mapping/infile/infile.xps" "-toPDF" "-outfile:/apps/mapping/output/out.pdf"
"-profile:pdf_signature"