From c85c1b734fa88dddfee40d52f483b224d291eb54 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Wed, 1 Apr 2015 11:24:39 -0600 Subject: [PATCH] Update README.md --- README.md | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8804181..cca54cc 100644 --- a/README.md +++ b/README.md @@ -112,7 +112,46 @@ them, or you just prefer to `https.globalAgent.options.ca = require('ssl-root-cas').rootCas;` yourself, well, you can. -BAD IDEAS +Kinda Bad Ideas +===== + +You could turn off ssl checking for a single request like so: + +```javascript + 'use strict'; + + var request = require('request'); + var agentOptions; + var agent; + + agentOptions = { + host: "www.example.com" + , port: "443" + , path: '/' + // This allows the single bad certificate + // instead of making your entire node process completely, utterly + , rejectUnauthorized: false + }; + + // If you were using a self-signed cert you would add this option: + // agentOptions.ca = [ selfSignedRootCaPemCrtBuffer ]; + + // For trusted-peer connections you would also add these 2 options: + // agentOptions.key = serverPemKeyBuffer; + // agentOptions.cert = serverPemCrtSignedBySelfSignedRootCaBuffer; + + agent = new https.Agent(agentOptions); + + request({ + url: "https://www.example.com/api/endpoint" + , method: 'GET' + , agent: agent + }, function (err, resp, body) { + // ... + }); +``` + +REALLY Bad Ideas === Don't use dissolutions such as these. :-)