2017-10-16 10 views

答えて

0

私はカスタムに.createConnection機能を作成することによって、それを行うための方法を見つけた

var tls=require("tls") 
var https=require("https") 

var options={ 
    host:"example.com", 
    port:443, 
    path:"/" 
} 
var agentOptions = { 
    rejectUnauthorized: true //this option disables certificate verification when it is false, you may need to disable it to connect to a server without having SNI enabled 
} 
var agent = new https.Agent(agentOptions) 
agent.createConnection=function(options,callback){ 
    options.servername=undefined //setting servername to undefined disables SNI 
    return socket=tls.connect(options,callback)  
} 
options.agent=agent 
request=https.request(options,function(response){ 

    response.on("data",function(data){ 
     console.log(data.toString()) 
    }) 

}) 
request.end() 
関連する問題