How to use the jsrsasign.X509 function in jsrsasign

To help you get started, we’ve selected a few jsrsasign 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 gchq / CyberChef / src / core / operations / PublicKey.js View on Github external
runPemToHex: function(input, args) {
        if (input.indexOf("-----BEGIN") < 0) {
            // Add header so that the KEYUTIL function works
            input = "-----BEGIN CERTIFICATE-----" + input;
        }
        if (input.indexOf("-----END") < 0) {
            // Add footer so that the KEYUTIL function works
            input = input + "-----END CERTIFICATE-----";
        }
        let cert = new r.X509();
        cert.readCertPEM(input);
        return cert.hex;
    },
github OpenXbox / xbox-smartglass-core-node / src / xbox.js View on Github external
connect: function()
        {
            // // Set liveid
            var pem = '-----BEGIN CERTIFICATE-----'+EOL+this.getCertificate().toString('base64').match(/.{0,64}/g).join('\n')+'-----END CERTIFICATE-----';
            var deviceCert = new jsrsasign.X509();
            deviceCert.readCertPEM(pem);

            // var hSerial    = deviceCert.getSerialNumberHex(); // '009e755e" hexadecimal string
            // var sIssuer    = deviceCert.getIssuerString();    // '/C=US/O=z2'
            // var sSubject   = deviceCert.getSubjectString();   // '/C=US/O=z2'
            // var sNotBefore = deviceCert.getNotBefore();       // '100513235959Z'
            // var sNotAfter  = deviceCert.getNotAfter();        // '200513235959Z'

            this.setLiveid(deviceCert.getSubjectString().slice(4))

            // Set uuid
            var uuid4 = Buffer.from(uuidParse.parse(uuid.v4()));

            // Create public key
            var ecKey = jsrsasign.X509.getPublicKeyFromCertPEM(pem);
github wireapp / wire-desktop / electron / src / js / certificateUtils.ts View on Github external
.digest('base64');
  } catch (error) {
    console.error(`Certificate verification failed: ${error.message}`, error);
    return {decoding: false};
  }

  const result: PinningResult = {};

  const errorMessages: string[] = [];

  for (const pin of pins) {
    const {url, publicKeyInfo = [], issuerRootPubkeys = []} = pin;

    if (url.test(hostname.toLowerCase().trim())) {
      if (issuerRootPubkeys.length > 0) {
        const x509 = new rs.X509();
        x509.readCertHex(issuerCertHex);

        result.verifiedIssuerRootPubkeys = issuerRootPubkeys.some(rawPublicKey => {
          const x509PublicKey = rs.KEYUTIL.getKey(rawPublicKey);
          return x509.verifySignature(x509PublicKey);
        });
        if (!result.verifiedIssuerRootPubkeys) {
          const errorMessage = `Issuer root public key signatures: none of "${issuerRootPubkeys.join(
            ', '
          )}" could be verified.`;
          errorMessages.push(errorMessage);
        }
      }

      result.verifiedPublicKeyInfo = publicKeyInfo
        .reduce((arr: (boolean | undefined)[], pubkey) => {
github accordproject / concerto / packages / composer-common / lib / certificate.js View on Github external
constructor(pem) {
        const method = 'constructor';
        LOG.entry(method, pem);
        this.pem = pem;
        this.certificate = new X509();
        this.certificate.readCertPEM(pem);
        this.publicKey = KEYUTIL.getPEM(this.certificate.getPublicKey());
        this.identifier = KJUR.crypto.Util.hashHex(this.certificate.getPublicKey().pubKeyHex, 'sha256');
        this.issuer = KJUR.crypto.Util.hashHex(this.certificate.getIssuerString(), 'sha256');
        this.name = /(\/CN=)(.*?)(\/|,|$)/.exec(this.certificate.getSubjectString())[2];
        LOG.exit(method);
    }
github beameio / beame-sdk / src / services / Credential.js View on Github external
_updateCertData() {
		//get x509 cert data
		try {
			const x509Path = this.beameStoreServices.getAbsoluteFileName(Config.CertFileNames.X509);

			const rs   = require('jsrsasign');
			const X509 = rs.X509;
			const fs   = require('fs');
			let pemStr = (fs.readFileSync(x509Path)).toString();
			let x      = new rs.X509();
			x.readCertPEM(pemStr);


			let hex          = X509.pemToHex(pemStr);
			let fingerprints = {
				    'sha1':   rs.KJUR.crypto.Util.hashHex(hex, 'sha1'),
				    'sha256': rs.KJUR.crypto.Util.hashHex(hex, 'sha256')
			    },
			    ai           = X509.getExtAIAInfo(hex),
			    alt          = X509.getExtSubjectAltName(hex),
			    keyUsageStr  = X509.getExtKeyUsageString(hex),
			    alg          = x.getSignatureAlgorithmField(),
			    subjectStr   = x.getSubjectString();

			let subject = {
				"commonName":   "",
github Kunstmaan / hyperledger-fabric-node-chaincode-utils / src / utils / identity.js View on Github external
const getCertificateFromPEM = function(pem) {
    const normalizedPEM = normalizeX509PEM(pem);

    const cert = new X509();
    cert.readCertPEM(normalizedPEM);

    return cert;
};
github gchq / CyberChef / src / core / operations / PublicKey.js View on Github external
runParseX509: function (input, args) {
        if (!input.length) {
            return "No input";
        }

        let cert = new r.X509(),
            inputFormat = args[0];

        switch (inputFormat) {
            case "DER Hex":
                input = input.replace(/\s/g, "");
                cert.readCertHex(input);
                break;
            case "PEM":
                cert.readCertPEM(input);
                break;
            case "Base64":
                cert.readCertHex(Utils.toHex(Utils.fromBase64(input, null, "byteArray"), ""));
                break;
            case "Raw":
                cert.readCertHex(Utils.toHex(Utils.strToByteArray(input), ""));
                break;

jsrsasign

opensource free pure JavaScript cryptographic library supports RSA/RSAPSS/ECDSA/DSA signing/validation, ASN.1, PKCS#1/5/8 private/public key, X.509 certificate, CRL, OCSP, CMS SignedData, TimeStamp and CAdES and JSON Web Signature(JWS)/Token(JWT)/Key(JWK)

MIT
Latest version published 11 months ago

Package Health Score

74 / 100
Full package analysis