I am able to authenticate and get some work item in my RTC localhost server https (self signed certificate), setting on unirest Request.strictSSL(false), but when I try to .attach() something, it does not works:
Code:
var cookies = unirest.jar();
async.waterfall([
(callback) => {
var req = unirest("POST", "https://localhost:9443/ccm/j_security_check")
.headers({
"Content-Type": "application/x-www-form-urlencoded",
})
.strictSSL(false)
.jar(cookies)
.send("j_username=samuel")
.send("j_password=samuel")
.end(function(res) {
if (res.error) throw new Error(res.error);
console.log('logged');
callback();
});
},
(callback) => {
var req = unirest("GET", "https://localhost:9443/ccm/resource/itemName/com.ibm.team.workitem.WorkItem/2")
.headers({
Accept: "application/json",
})
.jar(cookies)
.strictSSL(false)
.end(function(res) {
if (res.error) throw new Error(res.error);
console.log(res.raw_body);
callback();
});
},
(callback) => {
var req = unirest(
"POST",
"https://localhost:9443/ccm/service/com.ibm.team.workitem.service.internal.rest.IAttachmentRestService?projectId=_Jv0jwFXOEeuKc9Bmrq6cOA&multiple=true"
)
.strictSSL(false)
.jar(cookies)
.attach(
"file",
"https://url_to_img"
)
.end(function(res) {
if (res.error) {
console.error(res.error);
} else {
console.log('attach worked');
}
});
}
])
Output:
logged
{...workitem}
{ Error: self signed certificate
at TLSSocket.onConnectSecure (_tls_wrap.js:1058:34)
at TLSSocket.emit (events.js:198:13)
at TLSSocket._finishInit (_tls_wrap.js:636:8) code: 'DEPTH_ZERO_SELF_SIGNED_CERT' }
I was able to upload a file using Postman, setting the config "SSL certificate verification" to off.
So what I'm missing on unirest?
question from:
https://stackoverflow.com/questions/65832455/node-unirest-request-strictsslfalse-does-not-work-for-attach 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…