node-\/http-\/signature is a node.\+js library that has client and server components for Joyent\textquotesingle{}s \mbox{\hyperlink{md_sfcode_node_modules_http_signature_http_signing}{HTTP Signature Scheme}}.\hypertarget{md_sfcode_node_modules_http_signature_README_autotoc_md12415}{}\doxysection{Usage}\label{md_sfcode_node_modules_http_signature_README_autotoc_md12415}
Note the example below signs a request with the same key/cert used to start an HTTP server. This is almost certainly not what you actually want, but is just used to illustrate the API calls; you will need to provide your own key management in addition to this library.\hypertarget{md_sfcode_node_modules_http_signature_README_autotoc_md12416}{}\doxysubsection{Client}\label{md_sfcode_node_modules_http_signature_README_autotoc_md12416}

\begin{DoxyCode}{0}
\DoxyCodeLine{var fs = require('fs');}
\DoxyCodeLine{var https = require('https');}
\DoxyCodeLine{var httpSignature = require('http-\/signature');}
\DoxyCodeLine{}
\DoxyCodeLine{var key = fs.readFileSync('./key.pem', 'ascii');}
\DoxyCodeLine{}
\DoxyCodeLine{var options = \{}
\DoxyCodeLine{  host: 'localhost',}
\DoxyCodeLine{  port: 8443,}
\DoxyCodeLine{  path: '/',}
\DoxyCodeLine{  method: 'GET',}
\DoxyCodeLine{  headers: \{\}}
\DoxyCodeLine{\};}
\DoxyCodeLine{}
\DoxyCodeLine{// Adds a 'Date' header in, signs it, and adds the}
\DoxyCodeLine{// 'Authorization' header in.}
\DoxyCodeLine{var req = https.request(options, function(res) \{}
\DoxyCodeLine{  console.log(res.statusCode);}
\DoxyCodeLine{\});}
\DoxyCodeLine{}
\DoxyCodeLine{}
\DoxyCodeLine{httpSignature.sign(req, \{}
\DoxyCodeLine{  key: key,}
\DoxyCodeLine{  keyId: './cert.pem'}
\DoxyCodeLine{\});}
\DoxyCodeLine{}
\DoxyCodeLine{req.end(); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_http_signature_README_autotoc_md12417}{}\doxysubsection{Server}\label{md_sfcode_node_modules_http_signature_README_autotoc_md12417}

\begin{DoxyCode}{0}
\DoxyCodeLine{var fs = require('fs');}
\DoxyCodeLine{var https = require('https');}
\DoxyCodeLine{var httpSignature = require('http-\/signature');}
\DoxyCodeLine{}
\DoxyCodeLine{var options = \{}
\DoxyCodeLine{  key: fs.readFileSync('./key.pem'),}
\DoxyCodeLine{  cert: fs.readFileSync('./cert.pem')}
\DoxyCodeLine{\};}
\DoxyCodeLine{}
\DoxyCodeLine{https.createServer(options, function (req, res) \{}
\DoxyCodeLine{  var rc = 200;}
\DoxyCodeLine{  var parsed = httpSignature.parseRequest(req);}
\DoxyCodeLine{  var pub = fs.readFileSync(parsed.keyId, 'ascii');}
\DoxyCodeLine{  if (!httpSignature.verifySignature(parsed, pub))}
\DoxyCodeLine{    rc = 401;}
\DoxyCodeLine{}
\DoxyCodeLine{  res.writeHead(rc);}
\DoxyCodeLine{  res.end();}
\DoxyCodeLine{\}).listen(8443); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_http_signature_README_autotoc_md12418}{}\doxysection{Installation}\label{md_sfcode_node_modules_http_signature_README_autotoc_md12418}
\begin{DoxyVerb}npm install http-signature
\end{DoxyVerb}
 \hypertarget{md_sfcode_node_modules_http_signature_README_autotoc_md12419}{}\doxysection{License}\label{md_sfcode_node_modules_http_signature_README_autotoc_md12419}
MIT.\hypertarget{md_sfcode_node_modules_http_signature_README_autotoc_md12420}{}\doxysection{Bugs}\label{md_sfcode_node_modules_http_signature_README_autotoc_md12420}
See \href{https://github.com/joyent/node-http-signature/issues}{\texttt{ https\+://github.\+com/joyent/node-\/http-\/signature/issues}}. 