Skip to content

Setting .strictSSL(false) does not work for .attach() #138

@samuel-loupen

Description

@samuel-loupen

I am able to authenticate and get some work item in my RTC https local server setting 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://s3.amazonaws.com/cdn.freshdesk.com/data/helpdesk/attachments/production/8075345095/original/nicolas_cage.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAS6FNSMY2WD6T3JNC%2F20210120%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210120T164143Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=78fd8611c6a7c530937631d0f61d0c412c9a4f0d3d0a100eca919fa495e5c775"
            )
            .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' }

Am I missing something?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions