diff options
author | Dominik Picheta <dominikpicheta@googlemail.com> | 2018-01-20 17:33:06 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-20 17:33:06 +0000 |
commit | 588173496a592c58b0784d87d14b10a4487d41ae (patch) | |
tree | 369899cc5214022b638df4ba6f7b83e26461cbe2 /lib/wrappers/openssl.nim | |
parent | d127dd8095355af75c478fdec67da60ddbe709e6 (diff) | |
parent | be2db6d67a33f11f8abe1d7715932ec342a7f7e4 (diff) | |
download | Nim-588173496a592c58b0784d87d14b10a4487d41ae.tar.gz |
Merge pull request #7113 from endragor/static-openssl102
Allow static linking with OpenSSL 1.0.2
Diffstat (limited to 'lib/wrappers/openssl.nim')
-rw-r--r-- | lib/wrappers/openssl.nim | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/lib/wrappers/openssl.nim b/lib/wrappers/openssl.nim index 1d0dc5897..70d3887db 100644 --- a/lib/wrappers/openssl.nim +++ b/lib/wrappers/openssl.nim @@ -209,32 +209,38 @@ proc TLSv1_method*(): PSSL_METHOD{.cdecl, dynlib: DLLSSLName, importc.} when compileOption("dynlibOverride", "ssl"): # Static linking - proc OPENSSL_init_ssl*(opts: uint64, settings: uint8): cint {.cdecl, dynlib: DLLSSLName, importc, discardable.} - proc SSL_library_init*(): cint {.discardable.} = - ## Initialize SSL using OPENSSL_init_ssl for OpenSSL >= 1.1.0 - return OPENSSL_init_ssl(0.uint64, 0.uint8) - proc TLS_method*(): PSSL_METHOD {.cdecl, dynlib: DLLSSLName, importc.} - proc SSLv23_method*(): PSSL_METHOD = - TLS_method() + 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 SSL_library_init*(): cint {.discardable.} = + ## Initialize SSL using OPENSSL_init_ssl for OpenSSL >= 1.1.0 + return OPENSSL_init_ssl(0.uint64, 0.uint8) - 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.} + proc TLS_method*(): PSSL_METHOD {.cdecl, dynlib: DLLSSLName, importc.} + proc SSLv23_method*(): PSSL_METHOD = + TLS_method() - 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 = + ## Return OpenSSL version as unsigned long + OpenSSL_version_num() - proc getOpenSSLVersion*(): culong = - ## Return OpenSSL version as unsigned long - OpenSSL_version_num() + proc SSL_load_error_strings*() = + ## Removed from OpenSSL 1.1.0 + # This proc prevents breaking existing code calling SslLoadErrorStrings + # Static linking against OpenSSL < 1.1.0 is not supported + discard - proc SSL_load_error_strings*() = - ## Removed from OpenSSL 1.1.0 - # This proc prevents breaking existing code calling SslLoadErrorStrings - # Static linking against OpenSSL < 1.1.0 is not supported - 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: # Here we're trying to stay compatible with openssl 1.0.* and 1.1.*. Some |