Node Unirest Request.strictSSL(false) 不适用于 .attach()

问题描述

我能够在我的 RTC 本地主机服务器 https(自签名证书)中进行身份验证并获取一些工作项,在 unirest Request.strictSSL(false) 上设置,但是当我尝试 .attach() 时,它不起作用:

代码

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');
                }
            });
    }
])

输出

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' }

我能够使用 Postman 上传文件,将配置“SSL 证书验证”设置为关闭。 那么我在 unirest 上缺少什么?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...