Skip to content

Instantly share code, notes, and snippets.

@willmorgan
Last active June 22, 2017 08:41
Show Gist options
  • Save willmorgan/b8aa412c917dac3ec6a811626d15f640 to your computer and use it in GitHub Desktop.
Save willmorgan/b8aa412c917dac3ec6a811626d15f640 to your computer and use it in GitHub Desktop.
Azure Function crasher
const sshpk = require('sshpk');
function printClientCert(cert) {
return sshpk.parseCertificate(cert, 'x509');
}
module.exports = function (context, req) {
context.log(
printClientCert(Buffer.from(req.headers['x-arr-clientcert'], 'base64'))
);
context.res = {
status: 200,
headers: {
'Content-Type': 'text/json',
},
body: {
cert: printClientCert(Buffer.from(req.headers['x-arr-clientcert'], 'base64')),
},
};
context.done();
};
{
"disabled": false,
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"route": "cert",
"name": "req"
},
{
"type": "http",
"direction": "out",
"name": "res"
}
]
}
{
"name": "test-api",
"version": "1.0.0",
"description": "",
"main": "function.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "UNLICENSED",
"dependencies": {
"sshpk": "^1.13.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment