Skip to content

Support OpenSSL on Windows #11477

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

HertzDevil
Copy link
Contributor

@HertzDevil HertzDevil commented Nov 19, 2021

This PR adds OpenSSL 3.0.0 to Windows CI as a static library. Unlike on Linux, we do not have pkg-config on Windows, but we do have full control over the exact libraries used by Crystal, so this PR simply outputs the OpenSSL version number somewhere in Crystal::LIBRARY_PATH as part of the setup process, then uses the read_file? macro method to retrieve it at LibCrypto and LibSSL retrieves the version number from the CRYSTAL_OPENSSL_VERSION environment variable.

Building OpenSSL locally in the same manner as CI requires Strawberry Perl and NASM. Although this PR doesn't have it, I have also tried LibreSSL myself and everything works too (that one uses CMake and the Microsoft assembler).

OPENSSLDIR is left intact (C:\Program Files\Common Files\SSL).

This enables 295 passing and 2 pending examples, such as the remaining digest algorithms, in the standard library test suite.

@HertzDevil HertzDevil added kind:feature platform:windows Windows support based on the MSVC toolchain / Win32 API topic:stdlib:crypto labels Nov 19, 2021
{% if flag?(:win32) %}
@[Link("crypto")]
@[Link("crypt32")] # CertOpenStore, ...
@[Link("user32")] # GetProcessWindowStation, GetUserObjectInformationW, _MessageBoxW
Copy link
Member

Choose a reason for hiding this comment

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

Linking here seems unfortunate, particularly for _MessageBoxW :/
But seems like it couldn't be declared within OpenSSL itself?
https://github.com/openssl/openssl/blob/3e3ad3c54855dd534437871a0c78858de5e3d246/NOTES-WINDOWS.md?plain=1#L207

@straight-shoota straight-shoota added this to the 1.3.0 milestone Nov 20, 2021
@straight-shoota straight-shoota merged commit b10165e into crystal-lang:master Nov 23, 2021
@HertzDevil HertzDevil deleted the feature/windows-openssl branch November 29, 2021 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:feature platform:windows Windows support based on the MSVC toolchain / Win32 API topic:stdlib:crypto
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants