将TLS / SSL安全POST请求从node.js发送到IIS

我在Windows Server 2012上运行IIS 8.5(使用iisnode发布)上的node.js webapp,并将其configuration为使用我刚刚购买的此证书。 所以我把证书添加到服务器上:

在这里输入图像描述

并configuration我的网站使用https和我刚刚configuration的证书:

在这里输入图像描述

现在我可以访问我的网站,如https://example.com

好的,我有一些node.js客户端运行在我的networking之外的某些计算机上,并不时地向服务器发送一些数据。 我想保证这个连接,现在我有一个SSL证书。

我的目标是从客户端执行HTTPS POST,只有使用有效证书的客户端才能将数据上传到我的https://example.com/uploadurl。

所以首先,我强迫ISS在我的网站上申请证书。 在SSLconfiguration中,我选中了“Required”选项: 在这里输入图像描述

接下来要做的就是使用https和我的证书从我的node.js上传数据。 问题是我的node.js https POST请求获取IIS的权限拒绝网站作为回应。

我的node.js请求代码是:

var config = require('./config'); var request = require('request'); var path = require('path'); var fs = require('fs'); var certFile = path.resolve(__dirname, 'tls/certificate.crt'); var keyFile = path.resolve(__dirname, 'tls/certificate.key'); var caFile = path.resolve(__dirname, 'tls/certificate.ca.crt'); var pfxFile = path.resolve(__dirname, 'tls/certificate.pfx'); var credentials ={ "email":config.EMAIL, "password":config.PASSWORD } request.post({ uri: config.LOGIN_URL, //https://example.com/upload headers: { 'content-type': 'application/x-www-form-urlencoded', 'User-Agent' : 'Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko' }, body: require('querystring').stringify(credentials), rejectUnauthorized: false, agentOptions: { cert: fs.readFileSync(certFile), key: fs.readFileSync(keyFile), // Or use `pfx` property replacing `cert` and `key` when using private key, certificate and CA certs in PFX or PKCS12 format: // pfx: fs.readFileSync(pfxFilePath), ca: fs.readFileSync(caFile), securityOptions: 'SSL_OP_NO_SSLv3' } }, function(err, res, body){ if (!err && res.statusCode === 200) { console.log('OK!'); } else { console.log("Error: ",err); } }); 

我的架构中缺less什么,以便IIS允许我的HTTPS POST请求validation从客户端发送的证书?

编辑:我现在testing在node.js客户端ussing在服务器(IIS)中添加相同的pfx文件。 我的代理人现在是:

  agentOptions: { pfx: fs.readFileSync(pfxFile), passphrase: 'MyPfxPassPhrase', securityOptions: 'SSL_OP_NO_SSLv3' } 

同样的结果:(

编辑2:我使用免费的cloudflare服务作为DNS和一点额外的安全(DDos保护等)。 我不知道这是否会导致问题

编辑3:我在互联网上阅读,也许我必须创build一个与Windows用户一对一的映射,所以我按照本指南来configuration它。 同样的结果:403-权限被拒绝。

编辑4:我激活SSL错误跟踪,现在我可以看到确切的错误代码是: HTTP 403.16 Forbidden: Client Certificate Untrusted or Invalid. 确切地说,日志是:

 <failedRequest url="https://example.com:443/" siteId="6" appPoolId="example" processId="3544" verb="GET" authenticationType="NOT_AVAILABLE" activityId="{00000000-0000-0000-0D00-0080000000F7}" failureReason="STATUS_CODE" statusCode="403.16" triggerStatusCode="403.16" timeTaken="0" xmlns:freb="http://schemas.microsoft.com/win/2006/06/iis/freb" > </failedRequest> 

我不知道是否需要将COMODO RSA CA添加到受信任的根证书颁发机构证书存储区,中级证书颁发机构(CA)或外部根证书颁发机构中…我的证书具有以下证书path:

在这里输入图像描述

EDIT5:我用wireshark来捕获TLS协商。 这是结果,我无法得出任何结论:

在这里输入图像描述