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

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -