You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

server.js 811 B

12 years ago
12345678910111213141516171819202122232425262728
  1. var fs = require("fs")
  2. var https = require("https")
  3. var options = { key: fs.readFileSync("./server.key")
  4. , cert: fs.readFileSync("./server.crt") }
  5. var server = https.createServer(options, function (req, res) {
  6. res.writeHead(200)
  7. res.end()
  8. server.close()
  9. })
  10. server.listen(1337)
  11. var ca = fs.readFileSync("./ca.crt")
  12. var agent = new https.Agent({ host: "localhost", port: 1337, ca: ca })
  13. https.request({ host: "localhost"
  14. , method: "HEAD"
  15. , port: 1337
  16. , headers: { host: "testing.request.mikealrogers.com" }
  17. , agent: agent
  18. , ca: [ ca ]
  19. , path: "/" }, function (res) {
  20. if (res.client.authorized) {
  21. console.log("node test: OK")
  22. } else {
  23. throw new Error(res.client.authorizationError)
  24. }
  25. }).end()