Repository: promptfoo/promptfoo
Issue: HTTPS Calls Fail for https://localhost, reason:self-signed certificate
Root cause: Validation Gap

**Describe the bug**
When setting a provider to https://localhost so I can hit endpoints for local development, promptfoo's HTTPS calls fail after 4 retries.

**To Reproduce**
```yaml
description: 'Test eval'

prompts:
  - "{{testPrompt}}"

providers:
  - id: 'https://localhost:44800/chat'
    config:
      method: 'POST'
      headers:
        'Content-Type': 'application/json'
      body:
        message: '{{prompt}}'
      responseParser: 'json.output'
tests:
  - vars:
      testPrompt: Hello
```

1. Create a small API with an endpoint "/chat" and run it on https://localhost:44800 or any other port
2. Use the given config file as an example
3. Run `npx promptfoo eval`
4. Wait for it to complete
5. See error

**Expected behavior**
A successfull HTTP API call and response.

**Actual behaviour**
[FAIL] HTTP call error: Error: Request failed after 4 retries: request to https://localhost:44800/chat/ failed, reason: self-signed certificate

**System information (please complete the following information):**
Windows 11
Node v18.19.0 installed with NVM
- Promptfoo version: 0.75.0

**Additional context**
I was using an ASP.NET Web API locally and sending it the prompt to test its responses.

Have you tried with "http" in the URL instead of https?

On Wed, Aug 7, 2024, 2:41 AM Muhammad Rafay Nadeem ***@***.***>
wrote:

> *Describe the bug*
> When setting a provider to https://localhost:44800 so I can hit endpoints
> for local development, promptfoo's HTTPS calls fail after 4 retries.
>
> *To Reproduce*
>
> description: 'Test eval'
> prompts:
>   - "{{testPrompt}}"
> providers:
>   - id: 'https://localhost:44800/chat'
>     config:
>       method: 'POST'
>       headers:
>         'Content-Type': 'application/json'
>       body:
>         message: '{{prompt}}'
>       responseParser: 'json.output'tests:
>   - vars:
>       testPrompt: Hello
>
>
>    1. Create a small API with an endpoint "/chat" and run it on
>    localhost:44800 or any other port
>    2. Use the given config file as an example
>    3. Run npx promptfoo eval
>    4. Wait for it to complete
>    5. See error
>
> *Expected behavior*
> A successfull HTTP API call and response.
>
> *Screenshots*
> HTTP call error: Error: Request failed after 4 retries: request to
> https://localhost:44800/chat/ failed, reason: self-signed certificate
>
> *System information (please complete the following information):*
> Windows 11
> Node v18.19.0 installed with NVM
>
>    - Promptfoo version: 0.75.0
>
> *Additional context*
> I was using an ASP.NET Web API locally and sending it the prompt to test
> its responses.
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/promptfoo/promptfoo/issues/1388>, or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AACLYJQNODHV7IXMAP3LRBDZQHTT7AVCNFSM6AAAAABMEAYJTGVHI2DSMVQWIX3LMV43ASLTON2WKOZSGQ2TGMBUGA4TKMQ>
> .
> You are receiving this because you are subscribed to this thread.Message
> ID: ***@***.***>
>


Yes it works when it's http but not when it's https.

You can probably work around this by setting `NODE_TLS_REJECT_UNAUTHORIZED = "0"` (https://stackoverflow.com/q/52478069/219604)

#1396 will also solve

Landed in 0.76.0

I'm not sure about the security implications of removing the check but calls with HTTPS are working now. Thanks.