emanualjade / test-openapi

Automatic API integration testing
MIT License
14 stars 4 forks source link

Could not hit the endpoint with https #10

Closed shobero closed 6 years ago

shobero commented 6 years ago

Message: Could not connect to 'https://localhost:8000/test: request to https://localhost:8000/test failed, reason: certificate has expired

Plugin: call

ehmicky commented 6 years ago

Hi, thanks for reporting this.

What do you get when you try to reach this URL from your browser?

Also is your TLS certificate expired or self-signed?

shobero commented 6 years ago

I am able to get the response successfully through curl and postman but getting 'certificate expired error' on this.TLS certificate is self signed. Do we need to specify TLS details any where in tasks.yml?

shobero commented 6 years ago

I am able to access the url through curl and postman.

ehmicky commented 6 years ago

The problem is that node-fetch (the library I use) is based on https core module request, which by default does not accept self-signed certificates.

But it is possible to customize, so I can implement the following:

Add task property call.https as an object with the same options as https Agents like ca, cert, etc.

This should allow you using self-signed certificates, the same way you would with the https.request() Node.js core method.

What do you think?

ehmicky commented 6 years ago

I've added the feature as described above in latest release 41.1.0.

It is documented in the README.

For your particular case, you can try different combinations of HTTPS options and see which ones work. For example the following might do the trick, either:

- name: taskName
  call:
    https:
      rejectUnauthorized: false