Note that there are some explanatory texts on larger screens.

plurals
  1. POnode.js + restify - requiring client certificate
    primarykey
    data
    text
    <p>So I'm working on a basic node app. Clients will connect to it with SSL. It seems to work fine when I just use a server certificate, but when I attempt to require a client certificate, it continues to work no matter what I throw at it.</p> <p>I have found questions on this site related to this, but the answers contained therein didn't seem to work for me. <a href="https://stackoverflow.com/questions/10142431/my-node-js-https-client-always-works-regardless-of-certificate-validity?rq=1" title="Here&#39;s one.">Here's one.</a></p> <p>Here's relevant code:</p> <pre><code>var restify=require('restify'); var fs=require('fs'); var server=restify.createServer({ certificate: fs.readFileSync('../certs/server.crt'), key: fs.readFileSync('../certs/server.key'), ca: fs.readFileSync('../certs/ca.crt'), requestCert: true, rejectUnauthorized: true, }); ... server.listen(8080, function() { console.log('servers up...'); }); </code></pre> <p>I'm using curl to test connections, and pretty much anything that comes in causes the request object to be logged to console.</p> <p>The various curl command lines I've used are:</p> <pre><code>curl -k https://localhost:8080/hello curl -k -E user.combined:password https://localhost:8080/hello </code></pre> <p>I'm using -k because the certificates were generated locally and curl wants to validate them. (could this be the problem??)</p> <p>So, no matter what I send to the node instance, I get the output I'd expect if the user was using the proper certificate (as they are in the second curl command line above).</p> <p>Logged in the console, I see this:</p> <pre><code>req = { socket: { pair: _secureEstablished: true, _isServer: true, ... _rejectUnauthorized: false, _requestCert: false, (further down) authorized: false </code></pre> <p>Obviously, there's something going on here that I'm not fully up to speed on. What could it be?</p> <p>== UPDATE ==</p> <p>using -v with curl gets me some additional information, including this in the curl output:</p> <pre><code>* About to connect() to localhost port 8080 (#0) * Trying 127.0.0.1... connected * successfully set certificate verify locations: * CAfile: none CApath: /etc/ssl/certs </code></pre> <p>As noted above, my ca.crt file is in the (relative) directory ../certs</p> <p>Thank you.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload