1

クライアント証明書認証を主要な認証方法として使用するプログラムを作成しようとしています。このアプリケーションで使用したい Web サイト用に署名された証明書があります。http://blog.nategood.com/nodejs-ssl-client-cert-auth-api-restを読み、この人の記事で説明されているようにサーバーを実装する予定でしたが、署名された証明書をブラウザーに提示したいと思います、そして自分の認証局で keygen 属性を使用して生成された証明書に署名します。

コード例:

var https = require("https");
var http = require("http");
var fs = require("fs");

var options = {
    key:fs.readFileSync("./myserver.key"),
    cert:fs.readFileSync("./server.crt"),
    ca:fs.readFileSync("server.ca_bundle"),
    //I want to have a separate certificate for checking client certificates here, but I would be ok with any solution to the problem.
    requestCert:true,
    rejectUnauthorized: false   
};

https.createServer(options, function (req, res) {
    res.writeHead(200, "Content-type: text/plain");
    res.write("Authorized: "+JSON.stringify(req.client.authorized))
}).listen(443);
4

0 に答える 0