update-rootcerts.js
function getRootCerts(callback) {
  return request(certUrl, function(err, res, body) {
    if (err) return callback(err);

    // Delete preprocesor macros
    body = body.replace(/#[^\n]+/g, '');



    // Delete the trailing comma
    body = body.replace(/,\s*$/, '');

    // Make sure each C string is concatenated
    body = body.replace(/"\r?\n"/g, '');


    // Make sue we turn the cert names into property names
    body = body.replace(/\/\*([^*]+)\*\/\n(?=")/g, function(_, name) {
      var key = name.trim();
      return '"' + key + '":\n';
    });

    // Delete Comments
    body = body.replace(/\/\* tools\/\.\.\/src[^\0]+?\*\//, '');
    body = body.replace(/\/\* @\(#\)[^\n]+/, '');


    // \xff -> \u00ff
    body = body.replace(/\\x([0-9a-fA-F]{2})/g, '\\u00$1');

    // Trim Whitespace
    body = body.trim();

    // Wrap into a JSON Object
    body = '{\n' + body + '\n}\n';

    // Ensure JSON parses properly
    try {
      body = JSON.stringify(JSON.parse(body), null, 2);
    } catch (e) {
      return callback(e);
    }

    return callback(null, body);
  });
}
function getRootCerts(callback) {
  return request(certUrl, function(err, res, body) {
    if (err) return callback(err);

    // Delete preprocesor macros
    body = body.replace(/#[^\n]+/g, '');



    // Delete the trailing comma
    body = body.replace(/,\s*$/, '');

    // Make sure each C string is concatenated
    body = body.replace(/"\r?\n"/g, '');


    // Make sue we turn the cert names into property names
    body = body.replace(/\/\*([^*]+)\*\/\n(?=")/g, function(_, name) {
      var key = name.trim();
      return '"' + key + '":\n';
    });

    // Delete Comments
    body = body.replace(/\/\* tools\/\.\.\/src[^\0]+?\*\//, '');
    body = body.replace(/\/\* @\(#\)[^\n]+/, '');


    // \xff -> \u00ff
    body = body.replace(/\\x([0-9a-fA-F]{2})/g, '\\u00$1');

    // Trim Whitespace
    body = body.trim();

    // Wrap into a JSON Object
    body = '{\n' + body + '\n}\n';

    // Ensure JSON parses properly
    try {
      body = JSON.stringify(JSON.parse(body), null, 2);
    } catch (e) {
      return callback(e);
    }

    return callback(null, body);
  });
}
function getRootCerts ( callback ) { return request ( certUrl , function ( err , res , body ) { if ( err ) return callback ( err ) ; // Delete preprocesor macros body = body . replace ( / #[^\n]+ / g , '' ) ; // Delete the trailing comma body = body . replace ( / ,\s*$ / , '' ) ; // Make sure each C string is concatenated body = body . replace ( / "\r?\n" / g , '' ) ; // Make sue we turn the cert names into property names body = body . replace ( / \/\*([^*]+)\*\/\n(?=") / g , function ( _ , name ) { var key = name . trim ( ) ; return '"' + key + '":\n' ; } ) ; // Delete Comments body = body . replace ( / \/\* tools\/\.\.\/src[^\0]+?\*\/ / , '' ) ; body = body . replace ( / \/\* @\(#\)[^\n]+ / , '' ) ; // \xff -> \u00ff body = body . replace ( / \\x([0-9a-fA-F]{2}) / g , '\\u00$1' ) ; // Trim Whitespace body = body . trim ( ) ; // Wrap into a JSON Object body = '{\n' + body + '\n}\n' ; // Ensure JSON parses properly try { body = JSON . stringify ( JSON . parse ( body ) , null , 2 ) ; } catch ( e ) { return callback ( e ) ; } return callback ( null , body ) ; } ) ; }
Get Root Certs
Get Root Certs