diff --git a/lang/en.json b/lang/en.json index 52419a5aa134e8355fa0278f63b5a763edab54f2..09f1a98bbbea0d54e239c876fcfab59c351908c7 100755 --- a/lang/en.json +++ b/lang/en.json @@ -405,6 +405,7 @@ "validateDocumentWarning": "You are about to validate this document!", "certifiedDocument": "Certified document", "certifiedDocumentMsg": "The document was signed by digital certificate, you cannot affix a stamp.", - "errorUserSignType": "Signers without a certificate must be present before signers with a certificate." + "errorUserSignType": "Signers without a certificate must be present before signers with a certificate.", + "fortifyReadException": "Error when communicating with Fortify" } -} \ No newline at end of file +} diff --git a/lang/fr.json b/lang/fr.json index c15b60b5e50d5002f0bf4244b70d5d0919fce891..2320c6cfdf7416a5ec35b46b0f48db123a69b272 100755 --- a/lang/fr.json +++ b/lang/fr.json @@ -402,6 +402,7 @@ "validateDocumentWarning": "Vous êtes sur le point de valider ce document !", "certifiedDocument": "Document certifié", "certifiedDocumentMsg": "Le document a été signé par certificat numérique, vous ne pouvez pas apposer de griffe.", - "errorUserSignType": "Les signataires sans certificat doivent être présent avant les signataires avec certificat." + "errorUserSignType": "Les signataires sans certificat doivent être présent avant les signataires avec certificat.", + "fortifyReadException": "Erreur lors de la communication avec Fortify" } } diff --git a/src/frontend/app/service/signature-method/signature-method-modal.component.ts b/src/frontend/app/service/signature-method/signature-method-modal.component.ts index 69a2feb68c8bdf3c7bfa3ff3c54e39e626813d9e..43bde9276931f15018015d1f82c7740e98154884 100644 --- a/src/frontend/app/service/signature-method/signature-method-modal.component.ts +++ b/src/frontend/app/service/signature-method/signature-method-modal.component.ts @@ -65,10 +65,17 @@ export class SignatureMethodModalComponent implements OnInit { }).then(async (load: HTMLIonLoadingElement) => { load.present(); - this.provider = await certData.detail.server.getCrypto(certData.detail.providerId); - this.cert = await this.provider.certStorage.getItem(certData.detail.certificateId); - this.certPem = await this.provider.certStorage.exportCert('pem', this.cert); - this.privateKey = await this.provider.keyStorage.getItem(certData.detail.privateKeyId); + try { + this.provider = await certData.detail.server.getCrypto(certData.detail.providerId); + this.cert = await this.provider.certStorage.getItem(certData.detail.certificateId); + this.certPem = await this.provider.certStorage.exportCert('pem', this.cert); + this.privateKey = await this.provider.keyStorage.getItem(certData.detail.privateKeyId); + } catch (e) { + this.notificationService.error('lang.fortifyReadException'); + load.dismiss(); + this.modalController.dismiss(false); + return; + } this.certificate = { certificate: this.certPem @@ -94,7 +101,15 @@ export class SignatureMethodModalComponent implements OnInit { console.log('hashDocumentHex', hashDocumentHex); - const hashSignature = await this.provider.subtle.sign(alg, this.privateKey, hashDocumentHex); + let hashSignature; + try { + hashSignature = await this.provider.subtle.sign(alg, this.privateKey, hashDocumentHex); + } catch (e) { + this.notificationService.error('lang.fortifyReadException'); + resolve(false); + return of(false); + } + console.log('hashSignature', hashSignature);