<commit_before>// Copyright 2014 ISRG.  All rights reserved
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//
// To revoke a certificate against a local Boulder:
// js revoke.js cert.pem key.pem

'use strict';

var crypto = require('./crypto-util');
var util = require('./acme-util');
var forge = require('node-forge');
var fs = require('fs');
var request = require('request');

function main() {
  if (process.argv.length != 5) {
    console.log('Usage: js revoke.js cert.der key.pem REVOKE_URL');
    process.exit(1);
  }
  var key = crypto.importPemPrivateKey(fs.readFileSync(process.argv[3]));
  var certDER = fs.readFileSync(process.argv[2])
  var revokeUrl = process.argv[4];
  var certDERB64URL = util.b64enc(new Buffer(certDER))
  var revokeMessage = JSON.stringify({
    // For some reason forge adds an extra, incorrect '00' at the front of the
    // serial number.
    certificate: certDERB64URL
  });
  console.log('Requesting revocation:', revokeMessage)
  var jws = crypto.generateSignature(key, new Buffer(revokeMessage));
  var req = request.post(revokeUrl, function(err, resp) {
    if (err) {
      console.log('Error: ', err);
    }
    console.log(resp.statusCode);
    console.log(resp.headers);
    console.log(resp.body);
  });
  var payload = JSON.stringify(jws);
  console.log(payload);
  req.write(payload);
  req.end();
}
main();
<commit_msg>Fix failure mode in integration test.<commit_after>// Copyright 2014 ISRG.  All rights reserved
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//
// To revoke a certificate against a local Boulder:
// js revoke.js cert.pem key.pem

'use strict';

var crypto = require('./crypto-util');
var util = require('./acme-util');
var forge = require('node-forge');
var fs = require('fs');
var request = require('request');

function main() {
  if (process.argv.length != 5) {
    console.log('Usage: js revoke.js cert.der key.pem REVOKE_URL');
    process.exit(1);
  }
  var key = crypto.importPemPrivateKey(fs.readFileSync(process.argv[3]));
  var certDER = fs.readFileSync(process.argv[2])
  var revokeUrl = process.argv[4];
  var certDERB64URL = util.b64enc(new Buffer(certDER))
  var revokeMessage = JSON.stringify({
    // For some reason forge adds an extra, incorrect '00' at the front of the
    // serial number.
    certificate: certDERB64URL
  });
  console.log('Requesting revocation:', revokeMessage)
  var jws = crypto.generateSignature(key, new Buffer(revokeMessage));
  var req = request.post(revokeUrl, function(err, resp) {
    if (err) {
      console.log('Error: ', err);
      process.exit(1);
    }
    console.log(resp.statusCode);
    console.log(resp.headers);
    console.log(resp.body);
  });
  var payload = JSON.stringify(jws);
  console.log(payload);
  req.write(payload);
  req.end();
}
main();

{'fraction_non_alphanumeric': 0.14368743945753956, 'fraction_numerical': 0.013884404262189216, 'mean_word_length': 3.6307922272047835, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4693987', 'n_tokens_mistral': 1034, 'n_tokens_neox': 1003, 'n_words': 292}