Allow static linking with OpenSSL 1.0.x

This commit basically returns the code that was removed in
a78d7a31f7, but under 'openssl10'
define symbol. OpenSSL 1.0.2 is still actively maintained, so there is
no point in dropping support of it.
This commit is contained in:
Ruslan Mustakov 2018-01-20 19:10:52 +07:00
commit be2db6d67a
2 changed files with 31 additions and 23 deletions

View file

@ -217,4 +217,6 @@ setForegroundColor colRed
setBackgroundColor colGreen setBackgroundColor colGreen
styledEcho "Red on Green.", resetStyle styledEcho "Red on Green.", resetStyle
``` ```
- If you use ``--dynlibOverride:ssl`` with OpenSSL 1.0.x, you now have to
define ``openssl10`` symbol (``-d:openssl10``). By default OpenSSL 1.1.x is
assumed.

View file

@ -209,6 +209,12 @@ proc TLSv1_method*(): PSSL_METHOD{.cdecl, dynlib: DLLSSLName, importc.}
when compileOption("dynlibOverride", "ssl"): when compileOption("dynlibOverride", "ssl"):
# Static linking # Static linking
when defined(openssl10):
proc SSL_library_init*(): cint {.cdecl, dynlib: DLLSSLName, importc, discardable.}
proc SSL_load_error_strings*() {.cdecl, dynlib: DLLSSLName, importc.}
proc SSLv23_method*(): PSSL_METHOD {.cdecl, dynlib: DLLSSLName, importc.}
else:
proc OPENSSL_init_ssl*(opts: uint64, settings: uint8): cint {.cdecl, dynlib: DLLSSLName, importc, discardable.} proc OPENSSL_init_ssl*(opts: uint64, settings: uint8): cint {.cdecl, dynlib: DLLSSLName, importc, discardable.}
proc SSL_library_init*(): cint {.discardable.} = proc SSL_library_init*(): cint {.discardable.} =
## Initialize SSL using OPENSSL_init_ssl for OpenSSL >= 1.1.0 ## Initialize SSL using OPENSSL_init_ssl for OpenSSL >= 1.1.0
@ -218,12 +224,6 @@ when compileOption("dynlibOverride", "ssl"):
proc SSLv23_method*(): PSSL_METHOD = proc SSLv23_method*(): PSSL_METHOD =
TLS_method() TLS_method()
proc SSLv23_client_method*(): PSSL_METHOD {.cdecl, dynlib: DLLSSLName, importc.}
proc SSLv2_method*(): PSSL_METHOD {.cdecl, dynlib: DLLSSLName, importc.}
proc SSLv3_method*(): PSSL_METHOD {.cdecl, dynlib: DLLSSLName, importc.}
template OpenSSL_add_all_algorithms*() = discard
proc OpenSSL_version_num(): culong {.cdecl, dynlib: DLLSSLName, importc.} proc OpenSSL_version_num(): culong {.cdecl, dynlib: DLLSSLName, importc.}
proc getOpenSSLVersion*(): culong = proc getOpenSSLVersion*(): culong =
@ -236,6 +236,12 @@ when compileOption("dynlibOverride", "ssl"):
# Static linking against OpenSSL < 1.1.0 is not supported # Static linking against OpenSSL < 1.1.0 is not supported
discard discard
template OpenSSL_add_all_algorithms*() = discard
proc SSLv23_client_method*(): PSSL_METHOD {.cdecl, dynlib: DLLSSLName, importc.}
proc SSLv2_method*(): PSSL_METHOD {.cdecl, dynlib: DLLSSLName, importc.}
proc SSLv3_method*(): PSSL_METHOD {.cdecl, dynlib: DLLSSLName, importc.}
else: else:
# Here we're trying to stay compatible with openssl 1.0.* and 1.1.*. Some # Here we're trying to stay compatible with openssl 1.0.* and 1.1.*. Some
# symbols are loaded dynamically and we don't use them if not found. # symbols are loaded dynamically and we don't use them if not found.