How to use pem - 10 common examples

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 / pem / pem-tests.ts View on Github external
'Get DH param info': (test: any) => {
    var dh = ''; // fs.readFileSync('./test/fixtures/test.dh').toString();

    pem.getDhparamInfo(dh, (error: any, data: any) => {
      var size = data && data.size || 0;
      var prime = (data && data.prime || '').toString();
      test.ifError(error);
      test.equal(size, 1024);
      test.ok(prime);
      // test.ok(fs.readdirSync('./tmp').length === 0);
      test.equal(typeof size, 'number');
      test.ok(/([0-9a-f][0-9a-f]:)+[0-9a-f][0-9a-f]$/g.test(prime));
      test.done();
    });
  },
github DefinitelyTyped / DefinitelyTyped / types / pem / pem-tests.ts View on Github external
'Get DH param info': (test: any) => {
    const dh = ''; // fs.readFileSync('./test/fixtures/test.dh').toString();

    pem.getDhparamInfo(dh, (error: any, data: any) => {
      const size = data && data.size || 0;
      const prime = (data && data.prime || '').toString();
      test.ifError(error);
      test.equal(size, 1024);
      test.ok(prime);
      // test.ok(fs.readdirSync('./tmp').length === 0);
      test.equal(typeof size, 'number');
      test.ok(/([0-9a-f][0-9a-f]:)+[0-9a-f][0-9a-f]$/g.test(prime));
      test.done();
    });
  },
github DefinitelyTyped / DefinitelyTyped / types / pem / pem-tests.ts View on Github external
pem.createCSR((error: any, data: any) => {
      const csr = (data && data.csr || '').toString();
      test.ifError(error);
      // test.ok(fs.readdirSync('./tmp').length === 0);

      pem.readCertificateInfo(csr, (error: any, data: any) => {
        test.ifError(error);
        test.deepEqual(data, {
          issuer : {},
          country: '',
          state: '',
          locality: '',
          organization: '',
          organizationUnit: '',
          commonName: 'localhost',
          emailAddress: ''
        });
        // test.ok(fs.readdirSync('./tmp').length === 0);
        test.done();
      });
    });
  },
github DefinitelyTyped / DefinitelyTyped / pem / pem-tests.ts View on Github external
pem.createCSR({ csrConfigFile: './test/fixtures/test.cnf' }, (error: any, data: any) => {
      var csr = (data && data.csr || '').toString();
      test.ifError(error);
      test.ok(csr);
      test.ok(csr.match(/^\n*\-\-\-\-\-BEGIN CERTIFICATE REQUEST\-\-\-\-\-\n/));
      test.ok(csr.match(/\n\-\-\-\-\-END CERTIFICATE REQUEST\-\-\-\-\-\n*$/));

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

      pem.readCertificateInfo(csr, (error: any, data: any) => {
        test.ifError(error);
        test.deepEqual(data, certInfo);
        // test.ok(fs.readdirSync('./tmp').length === 0);
        test.done();
      });
    });
  },
github DefinitelyTyped / DefinitelyTyped / pem / pem-tests.ts View on Github external
pem.createCertificate((error: any, data: any) => {
      var certificate = (data && data.certificate || '').toString();
      test.ifError(error);
      // test.ok(fs.readdirSync('./tmp').length === 0);

      pem.readCertificateInfo(certificate, (error: any, data: any) => {
        test.ifError(error);

        if (data.validity) {
          delete data.validity;
        }
        if (data.serial) {
          delete data.serial;
        }

        test.deepEqual(data, {
          issuer : {
            country: '',
            state: '',
            locality: '',
            organization: '',
            organizationUnit: '',
github DefinitelyTyped / DefinitelyTyped / types / pem / pem-tests.ts View on Github external
'Create 2048bit Private key': (test: any) => {
    pem.createPrivateKey(2048, (error: any, data: any) => {
      const key = (data && data.key || '').toString();
      test.ifError(error);
      test.ok(key);
      test.ok(key.match(/^\n*\-\-\-\-\-BEGIN RSA PRIVATE KEY\-\-\-\-\-\n/));
      test.ok(key.match(/\n\-\-\-\-\-END RSA PRIVATE KEY\-\-\-\-\-\n*$/));
      test.ok(key.trim().length > 1650 && key.trim().length < 1700);
      // test.ok(fs.readdirSync('./tmp').length === 0);
      test.done();
    });
  },
github DefinitelyTyped / DefinitelyTyped / pem / pem-tests.ts View on Github external
'Create CSR with own encrypted key': (test: any) => {
    var password = 'my:secure! "password\'s\nawesome';
    pem.createPrivateKey(2048, { cipher: 'des3', password: password }, (error: any, data: any) => {
      var key = (data && data.key || '').toString();

      pem.createCSR({
                      clientKey: key,
                      clientKeyPassword: password
                    }, (error: any, data: any) => {
        var csr = (data && data.csr || '').toString();
        test.ifError(error);
        test.ok(csr);
        test.ok(csr.match(/^\n*\-\-\-\-\-BEGIN CERTIFICATE REQUEST\-\-\-\-\-\n/));
        test.ok(csr.match(/\n\-\-\-\-\-END CERTIFICATE REQUEST\-\-\-\-\-\n*$/));

        test.equal(data && data.clientKey, key);

        test.ok(data && data.clientKey);
        // test.ok(fs.readdirSync('./tmp').length === 0);
github DefinitelyTyped / DefinitelyTyped / pem / pem-tests.ts View on Github external
pem.createCertificate((error: any, data: any) => {
      var certificate = (data && data.certificate || '').toString();
      test.ifError(error);
      test.ok(certificate);
      // test.ok(fs.readdirSync('./tmp').length === 0);

      pem.getFingerprint(certificate, (error: any, data: any) => {
        var fingerprint = (data && data.fingerprint || '').toString();
        test.ifError(error);
        test.ok(fingerprint);
        test.ok(fingerprint.match(/^[0-9A-F]{2}(:[0-9A-F]{2}){19}$/));
        // test.ok(fs.readdirSync('./tmp').length === 0);

        test.done();
      });
    });
  },
github DefinitelyTyped / DefinitelyTyped / types / pem / pem-tests.ts View on Github external
pem.createCertificate((error: any, data: any) => {
      const certificate = (data && data.certificate || '').toString();
      test.ifError(error);
      test.ok(certificate);
      // test.ok(fs.readdirSync('./tmp').length === 0);

      pem.getFingerprint(certificate, (error: any, data: any) => {
        const fingerprint = (data && data.fingerprint || '').toString();
        test.ifError(error);
        test.ok(fingerprint);
        test.ok(fingerprint.match(/^[0-9A-F]{2}(:[0-9A-F]{2}){19}$/));
        // test.ok(fs.readdirSync('./tmp').length === 0);

        test.done();
      });
    });
  },
github DefinitelyTyped / DefinitelyTyped / types / pem / pem-tests.ts View on Github external
pem.createCertificate((error: any, data: any) => {
      const certificate = (data && data.certificate || '').toString();
      test.ifError(error);
      test.ok(certificate);
      // test.ok(fs.readdirSync('./tmp').length === 0);

      pem.getModulus(certificate, (error: any, data: any) => {
        const certmodulus = (data && data.modulus || '').toString();
        test.ifError(error);
        test.ok(certmodulus);
        test.ok(certmodulus.match(/^[0-9A-F]*$/));
        // test.ok(fs.readdirSync('./tmp').length === 0);
        pem.getModulus(certificate, (error: any, data: any) => {
          const keymodulus = (data && data.modulus || '').toString();
          test.ifError(error);
          test.ok(keymodulus);
          test.ok(keymodulus.match(/^[0-9A-F]*$/));
          test.ok(keymodulus === certmodulus);
          // test.ok(fs.readdirSync('./tmp').length === 0);
          test.done();
        });
      });
    });