node.js - Https two-way authentication with server using a public signed cert, but client using a private CA -
i'm node-js guy think certificate/ca only.
i want set https server using certificate signed public ca, browsers can visit website without certificate error. @ same time, want server provide two-way https authentication, server can recognize clients if clients using certificate. client certificate signed ca created myself.
when let client connect server, gets error called error: cert_untrusted. have set "ca" & "agent" option both server , client, can't figure out mistake.
i have installed self-signed ca in windows 8 root certificates, altough don't think it's needed.
my code:
server
var options = {     key:keyforcertificate,     cert:certfrompublicca,     ca:[publicca, self-signedca],     requestcert: true,     rejectunauthorized: false }; var server = require('https').server(options, require('express')()); server.listen(443); client
require('https').request({ host: "www.publicwebsite.com"     , method: "get"     , port: 443     , headers: { host: "www.publicwebsite.com" }     , ca:[publicca, self-signedca],     , path: "/" }, function (res) {     if (res.client.authorized) {         console.log("node test: ok")     } else {         throw new error(res.client.authorizationerror)     } }).end()  
 
  
Comments
Post a Comment