我正在尝试在带webpack的浏览器中运行get-ssl-certificate package,由于未定义getPeerCertificate
,它在尝试执行res.socket
函数时会中断:
var https = require("https");
https.get(options, function(res) {
var certificate = res.socket.getPeerCertificate();
});
这是检索到的res
对象:
{
"_readableState": {
"objectMode": false,
"highWaterMark": 16384,
"buffer": {
"head": null,
"tail": null,
"length": 0
},
"length": 0,
"pipes": null,
"pipesCount": 0,
"flowing": null,
"ended": false,
"endEmitted": false,
"reading": false,
"sync": true,
"needReadable": false,
"emittedReadable": false,
"readableListening": false,
"resumeScheduled": false,
"destroyed": false,
"defaultEncoding": "utf8",
"awaitDrain": 0,
"readingMore": false,
"decoder": null,
"encoding": null
},
"readable": true,
"_events": {
},
"_eventsCount": 2,
"_mode": "fetch",
"headers": {
"cache-control": "private, max-age=0",
"content-length": "63895",
"content-type": "text\/html; charset=UTF-8",
"expires": "-1"
},
"rawHeaders": [
"cache-control",
"private, max-age=0",
"content-length",
"63895",
"content-type",
"text\/html; charset=UTF-8",
"expires",
"-1"
],
"trailers": {
},
"rawTrailers": [
],
"_fetchResponse": {
},
"url": "https:\/\/www.google.com\/",
"statusCode": 200,
"statusMessage": ""
}
为什么socket
对象中没有res
?