net: don't call set_ecdh_auto for super old OpenSSL

And the fun thing is that currently we use a super old OpenSSL on
Windows.
This commit is contained in:
Leorize 2020-06-04 08:53:14 -05:00 • committed by Andreas Rumpf
commit 279438f1df
2 changed files with 4 additions and 6 deletions

View file

@ -585,7 +585,7 @@ when defineSsl:
# #
# From OpenSSL >= 1.1.0, this setting is set by default and can't be # From OpenSSL >= 1.1.0, this setting is set by default and can't be
# overriden. # overriden.
if newCTX.SSL_CTX_set_ecdh_auto(1) != 1: if getOpenSSLVersion() >= 0x10002000 and newCTX.SSL_CTX_set_ecdh_auto(1) != 1:
raiseSSLError() raiseSSLError()
when defined(nimDisableCertificateValidation) or defined(windows): when defined(nimDisableCertificateValidation) or defined(windows):

View file

@ -264,12 +264,10 @@ when compileOption("dynlibOverride", "ssl") or defined(noOpenSSLHacks):
proc SSL_library_init*(): cint {.cdecl, dynlib: DLLSSLName, importc, discardable.} proc SSL_library_init*(): cint {.cdecl, dynlib: DLLSSLName, importc, discardable.}
proc SSL_load_error_strings*() {.cdecl, dynlib: DLLSSLName, importc.} proc SSL_load_error_strings*() {.cdecl, dynlib: DLLSSLName, importc.}
proc SSLv23_method*(): PSSL_METHOD {.cdecl, dynlib: DLLSSLName, importc.} proc SSLv23_method*(): PSSL_METHOD {.cdecl, dynlib: DLLSSLName, importc.}
proc SSLeay(): culong {.cdecl, dynlib: DLLSSLName, importc.}
proc getOpenSSLVersion*(): culong = proc getOpenSSLVersion*(): culong =
## This interface is not supported for OpenSSL < 1.1.0 and will SSLeay()
## always return 0. The interface is provided to aid code
## supporting multiple OpenSSL versions.
0
else: 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.} =
@ -394,7 +392,7 @@ else:
proc getOpenSSLVersion*(): culong = proc getOpenSSLVersion*(): culong =
## Return OpenSSL version as unsigned long or 0 if not available ## Return OpenSSL version as unsigned long or 0 if not available
let theProc = cast[proc(): culong {.cdecl.}](sslSymNullable("OpenSSL_version_num")) let theProc = cast[proc(): culong {.cdecl.}](sslSymNullable("OpenSSL_version_num", "SSLeay"))
{.gcsafe.}: {.gcsafe.}:
result = result =
if theProc.isNil: 0.culong if theProc.isNil: 0.culong