Skip to content

Instantly share code, notes, and snippets.

@jbalthis
Forked from nicoster/softokend.js
Created July 11, 2014 22:13
Show Gist options
  • Save jbalthis/37576536e612cde040fd to your computer and use it in GitHub Desktop.
Save jbalthis/37576536e612cde040fd to your computer and use it in GitHub Desktop.
#!/usr/bin/env node
// the pathname of the url without the leading '/' is used as softoken pin
// so make the call with http://localhost:8000/<softoken-pin>
const https = require('https'),
fs = require("fs"),
url = require('url'),
exec = require('child_process').exec;
var options = {
key: fs.readFileSync('certs/pri.pem'),
cert: fs.readFileSync('certs/cert.pem')
};
var server = https.createServer(options, function (req, res) {
pin = url.parse(req.url, true).pathname.substr(1);
console.log(pin);
res.writeHead(200, {"Content-Type": "text/plain"});
exec('echo ' + pin + '|/Applications/SofToken\\ II.app/Contents/Resources/st-wrap.sh -s -p', function (error, stdout, stderr) {
res.end(stdout);
});
});
server.listen(8000);
console.log("Server running at https://127.0.0.1:8000/");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment