NodeJS authorizationError:'UNABLE_TO_VERIFY_LEAF_SIGNATURE',

时间:2016-07-28 07:27:40

标签: node.js https

我已尝试了所有可能的解决方案来解决此错误“UNABLE_TO_VERIFY_LEAF_SIGNATURE”。 GET请求正常。但由于证书问题,POST无法正常工作,     解决这个问题的任何帮助都会很棒。 以下是代码段

function dohttpRequest(requestdata,filename){
    //var localoptions=getOptions(requestdata);
    console.log('entered dohttpRequest');
    console.log(requestdata);
    var localoptions = {
                        //hostname: 'www.tele-servicingafrica.philips.com',
                        //hostname: '192.168.1.205',
                        hostname: '192.168.1.195',
                        key: fs.readFileSync('ssl/sca.key'),
                        cert: fs.readFileSync('ssl/sca.crt'),
                        ca:     fs.readFileSync('ssl/sia.crt'),
                        rejectUnauthorized: false,
                        strictssl:false,
                        port: 443,
                        path: '/ATS/ATS.Service1.svc/sftp/UploadFile',    
                        method: "POST",
                        json: true,
                        headers: {
                            "content-type": "application/json",
                            "content-length":requestdata.length
                            },
                        }
    process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = '0';
    var req = https.request(localoptions,function(res){
    console.log('entered request');
    res.setEncoding('utf8');

    console.log(res);
    console.log(req);
    res.on('data', function (chunk) {
        console.log('Status: ' + res.statusCode);
            if(res.statusCode=="200"){
                fs.unlink(filename);
                console.log('Status: ' + res.statusCode);
            }       
        });

    });

0 个答案:

没有答案