Egi*_*idi 5 iis ssl https request node.js
我在我的Windows Server 2012上运行IIS 8.5(使用iisnode发布)上运行的node.js webapp ,我已将其配置为使用我刚买的这个证书.所以我将证书添加到服务器:
并将我的网站配置为使用https和我刚刚配置的证书:
现在我可以访问我的网站,如https://example.com
好的,我的node.js客户端在网络外的某些计算机上运行,并且不时向服务器发送一些数据.我现在想拥有SSL证书,以确保连接安全.
我的目标是从客户端进行HTTPS POST,只允许使用有效证书的客户端将数据上传到我的https://example.com/upload网址.
首先,我强迫ISS在我的网站上要求证书.在SSL配置中,我检查了"必需"选项:
接下来要做的是使用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);
}
});
Run Code Online (Sandbox Code Playgroud)
我在架构中缺少什么,以便IIS允许我的HTTPS POST请求验证我从客户端发送的证书?
编辑:我现在正在测试node.js客户端我在服务器(IIS)中添加的相同pfx文件.我的agentOpntions现在是:
agentOptions: {
pfx: fs.readFileSync(pfxFile),
passphrase: 'MyPfxPassPhrase',
securityOptions: 'SSL_OP_NO_SSLv3'
}
Run Code Online (Sandbox Code Playgroud)
相同的结果:(
EDIT2:我使用免费的cloudflare服务作为DNS和一点额外的安全性(DDos保护等).我不知道这是否会导致这个问题......
编辑方式3:我在互联网上看到,也许我不得不与Windows用户创建一对一的映射,所以我按照本指南进行配置.相同的结果: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>
Run Code Online (Sandbox Code Playgroud)
我不知道是否需要将COMODO RSA CA添加到受信任的根证书颁发机构证书存储区,中间证书颁发机构(CA)或外部根证书颁发机构...我的证书具有以下证书路径:
EDIT5:我使用wireshark来捕获TLS协商.这是结果,我无法得出任何结论:
归档时间: |
|
查看次数: |
1101 次 |
最近记录: |