1

I'd like to collect information from privately installed Jira server but I've got a problem doing it.

Of course, I can connect the the site using my Chrome browser and it also find calling REST API from the browser address bar - https://myjiraaddr/rest/api/2/search

Sending REST API request using curl works okay with -u option(username:password) from command line.

But if I try it using nodejs and got an error says self signed certificate in certificate chain.

Can anybody please explain what makes these differences and how to fix it?

Thanks in advance :)

JiraApi = require('jira').JiraApi;

var jira = new JiraApi('https', 'myjiraaddress', 443, 'username', 'password', '2.0.alpha1');

jira.getCurrentUser(function(error, issue) {
    console.log(error);
});

it prints...

Status: Error: self signed certificate in certificate chain

And error if I use jira-client npm package...

RequestError: Error: self signed certificate in certificate chain
    at new RequestError (/Users/hyoon/dev/node/work-tracker/node_modules/request-promise-core/lib/errors.js:14:15)
    at Request.plumbing.callback (/Users/hyoon/dev/node/work-tracker/node_modules/request-promise-core/lib/plumbing.js:87:29)
    at Request.RP$callback [as _callback] (/Users/hyoon/dev/node/work-tracker/node_modules/request-promise-core/lib/plumbing.js:46:31)
    at self.callback (/Users/hyoon/dev/node/work-tracker/node_modules/request/request.js:185:22)
    at Request.emit (events.js:310:20)
    at Request.onRequestError (/Users/hyoon/dev/node/work-tracker/node_modules/request/request.js:877:8)
    at ClientRequest.emit (events.js:310:20)
    at TLSSocket.socketErrorListener (_http_client.js:426:9)
    at TLSSocket.emit (events.js:310:20)
    at emitErrorNT (internal/streams/destroy.js:92:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  cause: Error: self signed certificate in certificate chain
      at TLSSocket.onConnectSecure (_tls_wrap.js:1474:34)
      at TLSSocket.emit (events.js:310:20)
      at TLSSocket._finishInit (_tls_wrap.js:917:8)
      at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:687:12) {
    code: 'SELF_SIGNED_CERT_IN_CHAIN'
  },
  error: Error: self signed certificate in certificate chain
      at TLSSocket.onConnectSecure (_tls_wrap.js:1474:34)
      at TLSSocket.emit (events.js:310:20)
      at TLSSocket._finishInit (_tls_wrap.js:917:8)
      at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:687:12) {
    code: 'SELF_SIGNED_CERT_IN_CHAIN'
  },
Hongseok Yoon
  • 3,148
  • 8
  • 36
  • 51

1 Answers1

0

If you're dealing with a self-signed certificate you can bypass the strict-check by setting the strictSSL option to false, as described in the docs:

const jira = new JiraApi('https', 'myjiraaddress', 443, 'username', 'password', '2.0.alpha1', false, false);

If you do not want to bypass the check, you probably have to fork the library and modify the way the request is set up in order to add your certificate. See this question for more information: How do I use the node.js request module to make an SSL call with my own certificate?

eol
  • 23,236
  • 5
  • 46
  • 64