Skip to content

Detecting OpenSSL's version on Windows #11492

Closed
@HertzDevil

Description

@HertzDevil

Crystal detects libssl and libcrypto's versions during compilation time to bind to their APIs correctly. This is normally achieved using pkg-config; Windows doesn't have it, but we currently control all third-party libraries distributed together with Crystal, at least for portable packages (insofar as places like neatorobito/scoop-crystal and crystal-lang/install-crystal already rely on the Windows CI build artifacts). That means we can hardcode OpenSSL or LibreSSL's version number somewhere.

The current situation is to set the CRYSTAL_OPENSSL_VERSION environment variable. One way to improve it is writing the version number in a file called openssl_VERSION (or libressl_VERSION) placed somewhere under Crystal::LIBRARY_PATH, so that it can be read with macros:

{% ssl_version = nil %}
{% for dir in Crystal::LIBRARY_PATH.split(';') %}
  {% unless ssl_version %}
    {% config_path = "#{dir.id}\\openssl_VERSION" %}
    {% if config_version = read_file?(config_path) %}
      {% ssl_version = config_version.chomp %}
    {% end %}
  {% end %}
{% end %}
{% ssl_version ||= "0.0.0" %}

This is the original approach pursued in #11477.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions