Skip to content

undici Agent with connect.rejectUnauthorized: false doesn't bypass TLS verification #25481

@soundridge

Description

@soundridge

What version of Bun is running?

1.3.4

What platform is your computer?

macOS arm64

What steps can reproduce the bug?

Description

When using undici's Agent with the connect.rejectUnauthorized: false option, TLS certificate verification is not bypassed in Bun, but works correctly in Node.js.

Environment

  • Bun version: 1.3.4
  • Node.js version: 22.21.1 (works correctly)
  • undici version: 7.16.0
  • OS: macOS arm64

Minimal Reproduction

// minimal-repro.js
import { Agent, request } from 'undici';

const agent = new Agent({
  connect: {
    rejectUnauthorized: false,
  },
});

try {
  // Use a public test URL with self-signed certificate
  const result = await request('https://self-signed.badssl.com/', {
    dispatcher: agent,
    method: 'GET',
  });

  await result.body.text();
  console.log('✓ SUCCESS - Status:', result.statusCode);
} catch (err) {
  console.log('✗ FAILED -', err.code, ':', err.message);
}

Result in Node.js:

✓ SUCCESS - Status: 200

Result in Bun:

✗ FAILED - DEPTH_ZERO_SELF_SIGNED_CERT : self signed certificate

minimal-repro.js

package.json

What is the expected behavior?

The rejectUnauthorized: false option should bypass TLS certificate verification in both Node.js and Bun, allowing connections to servers with self-signed or invalid certificates.

What do you see instead?

No response

Additional information

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions