Merge pull request #17 from scottjw/main
Pin the signing certificate for validation
This commit is contained in:
commit
aab6cc4370
|
@ -41,15 +41,58 @@ async function loadPDF(signedPdfBuffer : ArrayBuffer): Promise<any> {
|
||||||
const certs = getCertificatesInfoFromPDF(signedPdfBuffer);
|
const certs = getCertificatesInfoFromPDF(signedPdfBuffer);
|
||||||
|
|
||||||
const result = certs[0];
|
const result = certs[0];
|
||||||
const isClientCertificate = result.clientCertificate;
|
const refcert = '-----BEGIN CERTIFICATE-----\r\n'+
|
||||||
const issuedByEntrust = (result.issuedBy.organizationName == 'Entrust, Inc.');
|
'MIIHNTCCBh2gAwIBAgIQanhJa+fBXT8GQ8QG/t9p4TANBgkqhkiG9w0BAQsFADCB\r\n'+
|
||||||
const issuedToOntarioHealth = (result.issuedTo.commonName == 'covid19signer.ontariohealth.ca');
|
'ujELMAkGA1UEBhMCVVMxFjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xKDAmBgNVBAsT\r\n'+
|
||||||
console.log(`PDF is signed by ${result.issuedBy.organizationName}, issued to ${result.issuedTo.commonName}`);
|
'H1NlZSB3d3cuZW50cnVzdC5uZXQvbGVnYWwtdGVybXMxOTA3BgNVBAsTMChjKSAy\r\n'+
|
||||||
|
'MDE0IEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXplZCB1c2Ugb25seTEuMCwG\r\n'+
|
||||||
|
'A1UEAxMlRW50cnVzdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEwxTTAeFw0y\r\n'+
|
||||||
|
'MTA1MjAxMzQxNTBaFw0yMjA2MTkxMzQxNDlaMIHTMQswCQYDVQQGEwJDQTEQMA4G\r\n'+
|
||||||
|
'A1UECBMHT250YXJpbzEQMA4GA1UEBxMHVG9yb250bzETMBEGCysGAQQBgjc8AgED\r\n'+
|
||||||
|
'EwJDQTEYMBYGCysGAQQBgjc8AgECEwdPbnRhcmlvMRcwFQYDVQQKEw5PbnRhcmlv\r\n'+
|
||||||
|
'IEhlYW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r4a7gczvt7+HFJRn//Q2fwhmaw\r\n'+
|
||||||
|
'vXTLLxcAPQF00G6ySsc9MUbsArh6AVhMf9tSXgNaTDj3X3UyYDfR+G8H9eVG/LPp\r\n'+
|
||||||
|
'34QV/8uvPUFXGj6MjdQysx6YG+K3mae0GEVpODEl4MiceEFZ7v4CPA6pFNadijRF\r\n'+
|
||||||
|
'6tdXky2psuo7VXfnE2WIlahKr56x+8R6To5pcWglKTywTqvCbnKRRVZhXXYo3Awd\r\n'+
|
||||||
|
'8h9+TbL3ACHDqA4fi5sAbZ7nMXp8RK4o5A==\r\n'+
|
||||||
|
'-----END CERTIFICATE-----';
|
||||||
|
|
||||||
|
const issuedpemCertificate = ( result.pemCertificate.trim() == refcert.trim());
|
||||||
|
|
||||||
|
//console.log(`pdf is signed by this cert ${result.pemCertificate.trim()}`);
|
||||||
|
//console.log(issuedpemCertificate);
|
||||||
|
//console.log(`PDF is signed by ${result.issuedBy.organizationName}, issued to ${result.issuedTo.commonName}`);
|
||||||
|
|
||||||
// const bypass = window.location.href.includes('grassroots2');
|
// const bypass = window.location.href.includes('grassroots2');
|
||||||
|
|
||||||
if ((isClientCertificate && issuedByEntrust && issuedToOntarioHealth)) {
|
if (( issuedpemCertificate )) {
|
||||||
console.log('getting receipt details inside PDF');
|
//console.log('getting receipt details inside PDF');
|
||||||
const receipt = await getPdfDetails(signedPdfBuffer);
|
const receipt = await getPdfDetails(signedPdfBuffer);
|
||||||
// console.log(JSON.stringify(receipt, null, 2));
|
// console.log(JSON.stringify(receipt, null, 2));
|
||||||
return Promise.resolve(receipt);
|
return Promise.resolve(receipt);
|
||||||
|
|
Loading…
Reference in New Issue