Skip to content

fix: resolve peer certificate symbols dynamically on Windows - #645

Merged
fox0430 merged 1 commit into
fox0430:mainfrom
canermastan:fix/windows-ssl-peer-certificate
Sep 22, 2026
Merged

fox0430 merged 1 commit into
fox0430:mainfrom
canermastan:fix/windows-ssl-peer-certificate

Conversation

@canermastan

Copy link
Copy Markdown
Contributor

Summary

Fixes compilation with -d:ssl on Windows when using the asyncdispatch backend.

std/openssl does not declare SSL_get_peer_certificate or X509_free
on Windows, so directly calling them prevents dependent projects from
compiling.

This resolves the OpenSSL symbols dynamically instead:

  • prefers SSL_get1_peer_certificate for OpenSSL 3
  • falls back to SSL_get_peer_certificate for older OpenSSL versions
  • resolves X509_free from libcrypto

This preserves SCRAM-SHA-256-PLUS channel binding when the installed OpenSSL
library supports it. If the required symbols are genuinely unavailable,
cbPrefer falls back safely and cbRequire continues to fail explicitly.

Related downstream report:
canermastan/jazzy-framework#33

Validation

Tested on Windows with Nim 2.2.12:

  • nim check -d:ssl async_postgres.nim
  • nim check tests/test_ssl.nim
  • compiled a Jazzy application with -d:ssl against this branch

@fox0430
fox0430 merged commit 2ff1a4a into fox0430:main Sep 22, 2026
4 checks passed
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.

2 participants