Skip to content

Instantly share code, notes, and snippets.

@Carlos-Augusto
Created November 1, 2021 06:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Carlos-Augusto/d10ade16400cfea5ae8dcf371f236cd0 to your computer and use it in GitHub Desktop.
Save Carlos-Augusto/d10ade16400cfea5ae8dcf371f236cd0 to your computer and use it in GitHub Desktop.
"use strict";
const fetch = require('node-fetch');
const https = require('https');
const fs = require('fs');
const pfx_file = fs.readFileSync(__dirname + "/PFX.pfx");
const ping = async (stage) => {
if (stage === "") {
throw new Error("Stage can't be empty.")
}
const httpsAgent = new https.Agent({
keepAlive: true,
pfx: pfx_file,
passphrase: "PASSPHRASE"
});
const url = "https://api.certify." + stage + ".ubirch.com"
const resp = await fetch(url, {
method: 'get',
agent: (_parsedURL) => {
return httpsAgent;
}
});
if (resp.status > 299) {
throw Error("response_status=" + resp.status);
}
return resp.buffer();
};
module.exports = {ping: ping};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment