Skip to content

Conversation

brycebaril
Copy link
Contributor

  • Fix: Exclude tlsOptions from Client constructor for ldap:// URLs
  • Fix: Only pass tlsOptions to startTLS() method, not constructor
  • Add: Comprehensive test suite for StartTLS functionality
  • Add: Documentation and examples for StartTLS usage
  • Update: docker-compose.yml image version for better availability

This fixes the issue where using StartTLS with tlsOptions would cause an immediate ECONNRESET error. The problem was that tlsOptions were being passed to both the ldapts.Client constructor and the startTLS() method, causing a protocol conflict.

According to ldapts documentation:

  • For ldaps:// URLs: pass tlsOptions to Client constructor
  • For ldap:// URLs with StartTLS: pass tlsOptions only to startTLS()

The fix properly detects the protocol and routes tlsOptions accordingly, enabling StartTLS to work with self-signed certificates, SNI, and other TLS configuration options.

Fixes #86

@shaozi
Copy link
Owner

shaozi commented Oct 11, 2025

Darn it! Bitnami takes openldap container image off the docker hub and paywalled it. I need to try a different image in order to run the tests. Sigh!

@shaozi
Copy link
Owner

shaozi commented Oct 11, 2025

Good job though @brycebaril !

@shaozi
Copy link
Owner

shaozi commented Oct 12, 2025

@brycebaril , I have updated the upstream master branch to use symas/openldap container image for testing. Also updated three test cases to match the new ldap server's behavior. I hope it does not cause conflict with your changes!

Can you rebase?

- Fix: Exclude tlsOptions from Client constructor for ldap:// URLs
- Fix: Only pass tlsOptions to startTLS() method, not constructor
- Add: Comprehensive test suite for StartTLS functionality
- Add: Documentation and examples for StartTLS usage
- Update: docker-compose.yml image version for better availability

This fixes the issue where using StartTLS with tlsOptions would cause
an immediate ECONNRESET error. The problem was that tlsOptions were
being passed to both the ldapts.Client constructor and the startTLS()
method, causing a protocol conflict.

According to ldapts documentation:
- For ldaps:// URLs: pass tlsOptions to Client constructor
- For ldap:// URLs with StartTLS: pass tlsOptions only to startTLS()

The fix properly detects the protocol and routes tlsOptions accordingly,
enabling StartTLS to work with self-signed certificates, SNI, and other
TLS configuration options.

Fixes shaozi#86
@brycebaril brycebaril force-pushed the fix-starttls-econnreset branch from 4624bdb to 9d2b4b7 Compare October 12, 2025 02:20
@brycebaril
Copy link
Contributor Author

Thank you for taking a look! Rebased and force pushed.

Copy link
Owner

@shaozi shaozi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks nice!

@shaozi shaozi merged commit 122be17 into shaozi:master Oct 12, 2025
6 checks passed
@shaozi
Copy link
Owner

shaozi commented Oct 12, 2025

Released in v3.3.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

StartTLS over LDAP fails with ECONNRESET on Node 22 using [email protected] (OpenSSL 3). openssl s_client -starttls ldap succeeds

2 participants