Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: corrected the strictSSL setting for the jira client #1

Merged
merged 1 commit into from
Apr 1, 2024

Conversation

Batyodie
Copy link
Contributor

I have found a bug when working in development mode for a real Jira client.

I use ngrok to create https for my node backend. When using your library, I pass strictSSL in the client settings:

 this.jiraRestApi = new JiraApi({
        protocol: 'https',
        host: jiraHost,
        username: jiraUsername,
        password: jiraPassword,
        apiVersion: 2,
        timeout: 5000,
        strictSSL: false,
});

As a result, when a POST request is sent, the request fails with errors.

cause: Error: unable to verify the first certificate
      at TLSSocket.onConnectSecure (node:_tls_wrap:1674:34)
      at TLSSocket.emit (node:events:518:28)
      at TLSSocket._finishInit (node:_tls_wrap:1085:8)
      at TLSWrap.ssl.onhandshakedone (node:_tls_wrap:871:12) {
    code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE'
  }

When using the classic Jira client, there was no such problem, so I started looking at the sources and discovered the difference

//  Extract from the original client where strictSSL is added
makeRequestHeader(uri, options = {}) {
    return {
      rejectUnauthorized: this.strictSSL,
      method: options.method || 'GET',
      uri,
      json: true,
      ...options
    };
  }
// Your code snippet
 else if ("strictSSL" in options || "ca" in options) {
            this.httpsAgent = new https_1.Agent({ rejectUnauthorized: !options.strictSSL, ca: options.ca });
            this.axios = axios_1.default.create({
                httpsAgent: this.httpsAgent,
            });
        }

Apparently the bug was in a wrong negation(!options.strictSSL), and there was also a bug in the tests that failed to check this script.

this.jiraRestApi = new JiraApi({
        protocol: 'https',
        host: jiraHost,
        username: jiraUsername,
        password: jiraPassword,
        apiVersion: 2,
        timeout: 5000,
        strictSSL: false,
      });
      console.log(this.jiraRestApi.axios.defaults?.httpsAgent.options); //  strictSSL is true

It turns out that when strictSSL is disabled, on the contrary, it is enabled.
Fixed this behaviour and added tests.

@Aeolun
Copy link
Owner

Aeolun commented Apr 1, 2024

Whoops, yeah. That triple negation there still required me to look at it a bunch before I saw the problem. Thanks for fixing it!

@Aeolun Aeolun merged commit 03da7b2 into Aeolun:main Apr 1, 2024
6 checks passed
github-actions bot pushed a commit that referenced this pull request Apr 1, 2024
## [1.0.2](v1.0.1...v1.0.2) (2024-04-01)

### Bug Fixes

* corrected the strictSSL setting for the jira client ([#1](#1)) ([03da7b2](03da7b2))
Copy link

github-actions bot commented Apr 1, 2024

🎉 This PR is included in version 1.0.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants