How to use the pem.readPkcs12 function in pem

To help you get started, we’ve selected a few pem examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / types / pem / pem-tests.ts View on Github external
// test.ok(fs.readdirSync('./tmp').length === 0);
          const pkcs12Buffer = new Buffer(pkcs12.pkcs12);

          pem.readPkcs12(pkcs12Buffer, (error: any, keystore: pem.Pkcs12ReadResult) => {
            test.ifError(error);
            test.ok(keystore);

            test.equal(ca.certificate, keystore.ca[0]);
            test.equal(cert.certificate, keystore.cert);
            test.equal(cert.clientKey, keystore.key);
          });

          const pkcs12File: string = __dirname + '/test.pkcs12';
          fs.writeFileSync(pkcs12File, pkcs12Buffer);

          pem.readPkcs12(pkcs12File, (error: any, keystore: pem.Pkcs12ReadResult) => {
            test.ifError(error);
            test.ok(keystore);

            test.equal(ca.certificate, keystore.ca[0]);
            test.equal(cert.certificate, keystore.cert);
            test.equal(cert.clientKey, keystore.key);

            test.done();
          });
        });
      });
github DefinitelyTyped / DefinitelyTyped / pem / pem-tests.ts View on Github external
pem.createPkcs12(cert.clientKey, cert.certificate, '', {certFiles: [ca.certificate]}, (error: any, pkcs12: any) => {
          test.ifError(error);
          test.ok(pkcs12.pkcs12);

          // test.ok(fs.readdirSync('./tmp').length === 0);

          pem.readPkcs12(pkcs12.pkcs12, (error: any, keystore: any) => {
            test.ifError(error);
            test.ok(keystore);

            test.equal(ca.certificate, keystore.ca[0]);
            test.equal(cert.certificate, keystore.cert);
            test.equal(cert.clientKey, keystore.key);

            test.done();
          });
        });
      });
github DefinitelyTyped / DefinitelyTyped / types / pem / pem-tests.ts View on Github external
pem.createPkcs12(cert.clientKey, cert.certificate, '', {certFiles: [ca.certificate]}, (error: any, pkcs12: any) => {
          test.ifError(error);
          test.ok(pkcs12.pkcs12);

          // test.ok(fs.readdirSync('./tmp').length === 0);
          const pkcs12Buffer = new Buffer(pkcs12.pkcs12);

          pem.readPkcs12(pkcs12Buffer, (error: any, keystore: pem.Pkcs12ReadResult) => {
            test.ifError(error);
            test.ok(keystore);

            test.equal(ca.certificate, keystore.ca[0]);
            test.equal(cert.certificate, keystore.cert);
            test.equal(cert.clientKey, keystore.key);
          });

          const pkcs12File: string = __dirname + '/test.pkcs12';
          fs.writeFileSync(pkcs12File, pkcs12Buffer);

          pem.readPkcs12(pkcs12File, (error: any, keystore: pem.Pkcs12ReadResult) => {
            test.ifError(error);
            test.ok(keystore);

            test.equal(ca.certificate, keystore.ca[0]);
github DefinitelyTyped / DefinitelyTyped / pem / pem-tests.ts View on Github external
'Respond with ENOENT for missing PKCS12 file': (test: any) => {
    pem.readPkcs12('/i/do/not/exist.p12', (error: any) => {
      test.ok(error);
      test.equal(error.code, 'ENOENT');

      test.done();
    });
  },
  'Verify sigining chain': (test: any) => {
github DefinitelyTyped / DefinitelyTyped / types / pem / pem-tests.ts View on Github external
'Respond with ENOENT for missing PKCS12 file': (test: any) => {
    pem.readPkcs12('/i/do/not/exist.p12', (error: any) => {
      test.ok(error);
      test.equal(error.code, 'ENOENT');

      test.done();
    });
  },
  'Verify sigining chain': (test: any) => {
github smartdevicelink / sdl_server / app / v1 / helpers / certificates.js View on Github external
return new Promise((resolve, reject) => {
        pem.readPkcs12(certBuffer, { //unlock it with the settings password
            p12Password: settings.securityOptions.passphrase
        }, function (err, res) {
            if (err) {
                return reject(err);
            }
            return resolve(res);
        });
    });
}