In case of synliboverride we support only openssl 1.0.*
This commit is contained in:
parent
975477527a
commit
581c0c437b
2 changed files with 64 additions and 51 deletions
|
|
@ -226,6 +226,8 @@ proc testCompileOptionArg*(switch, arg: string, info: TLineInfo): bool =
|
||||||
of "staticlib": result = contains(gGlobalOptions, optGenStaticLib) and
|
of "staticlib": result = contains(gGlobalOptions, optGenStaticLib) and
|
||||||
not contains(gGlobalOptions, optGenGuiApp)
|
not contains(gGlobalOptions, optGenGuiApp)
|
||||||
else: localError(info, errGuiConsoleOrLibExpectedButXFound, arg)
|
else: localError(info, errGuiConsoleOrLibExpectedButXFound, arg)
|
||||||
|
of "dynliboverride":
|
||||||
|
result = isDynlibOverride(arg)
|
||||||
else: invalidCmdLineOption(passCmd1, switch, info)
|
else: invalidCmdLineOption(passCmd1, switch, info)
|
||||||
|
|
||||||
proc testCompileOption*(switch: string, info: TLineInfo): bool =
|
proc testCompileOption*(switch: string, info: TLineInfo): bool =
|
||||||
|
|
|
||||||
|
|
@ -187,58 +187,73 @@ const
|
||||||
BIO_C_DO_STATE_MACHINE = 101
|
BIO_C_DO_STATE_MACHINE = 101
|
||||||
BIO_C_GET_SSL = 110
|
BIO_C_GET_SSL = 110
|
||||||
|
|
||||||
# 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.
|
|
||||||
proc thisModule(): LibHandle {.inline.} =
|
|
||||||
var thisMod {.global.}: LibHandle
|
|
||||||
if thisMod.isNil: thisMod = loadLib()
|
|
||||||
result = thisMod
|
|
||||||
|
|
||||||
proc sslModule(): LibHandle {.inline.} =
|
|
||||||
var sslMod {.global.}: LibHandle
|
|
||||||
if sslMod.isNil: sslMod = loadLibPattern(DLLSSLName)
|
|
||||||
result = sslMod
|
|
||||||
|
|
||||||
proc sslSym(name: string): pointer =
|
|
||||||
var dl = thisModule()
|
|
||||||
if not dl.isNil:
|
|
||||||
result = symAddr(dl, name)
|
|
||||||
if result.isNil:
|
|
||||||
dl = sslModule()
|
|
||||||
if not dl.isNil:
|
|
||||||
result = symAddr(dl, name)
|
|
||||||
|
|
||||||
proc SSL_library_init*(): cint {.discardable.} =
|
|
||||||
let theProc = cast[proc(): cint {.cdecl.}](sslSym("SSL_library_init"))
|
|
||||||
if not theProc.isNil: result = theProc()
|
|
||||||
|
|
||||||
proc SSL_load_error_strings*() =
|
|
||||||
let theProc = cast[proc() {.cdecl.}](sslSym("SSL_load_error_strings"))
|
|
||||||
if not theProc.isNil: theProc()
|
|
||||||
|
|
||||||
proc ERR_load_BIO_strings*(){.cdecl, dynlib: DLLUtilName, importc.}
|
|
||||||
|
|
||||||
proc TLSv1_method*(): PSSL_METHOD{.cdecl, dynlib: DLLSSLName, importc.}
|
proc TLSv1_method*(): PSSL_METHOD{.cdecl, dynlib: DLLSSLName, importc.}
|
||||||
|
|
||||||
proc SSLv23_client_method*(): PSSL_METHOD {.deprecated.} =
|
when compileOption("dynlibOverride", "ssl"):
|
||||||
let theProc = cast[proc(): PSSL_METHOD {.cdecl, gcsafe.}](sslSym("SSLv23_client_method"))
|
proc SSL_library_init*(): cint {.cdecl, dynlib: DLLSSLName, importc, discardable.}
|
||||||
if not theProc.isNil: result = theProc()
|
proc SSL_load_error_strings*() {.cdecl, dynlib: DLLSSLName, importc.}
|
||||||
else: result = TLSv1_method()
|
proc SSLv23_client_method*(): PSSL_METHOD {.cdecl, dynlib: DLLSSLName, importc.}
|
||||||
|
|
||||||
proc SSLv23_method*(): PSSL_METHOD {.deprecated.} =
|
proc SSLv23_method*(): PSSL_METHOD {.cdecl, dynlib: DLLSSLName, importc.}
|
||||||
let theProc = cast[proc(): PSSL_METHOD {.cdecl, gcsafe.}](sslSym("SSLv23_method"))
|
proc SSLv2_method*(): PSSL_METHOD {.cdecl, dynlib: DLLSSLName, importc.}
|
||||||
if not theProc.isNil: result = theProc()
|
proc SSLv3_method*(): PSSL_METHOD {.cdecl, dynlib: DLLSSLName, importc.}
|
||||||
else: result = TLSv1_method()
|
|
||||||
|
|
||||||
proc SSLv2_method*(): PSSL_METHOD {.deprecated.} =
|
template OpenSSL_add_all_algorithms*() = discard
|
||||||
let theProc = cast[proc(): PSSL_METHOD {.cdecl, gcsafe.}](sslSym("SSLv2_method"))
|
else:
|
||||||
if not theProc.isNil: result = theProc()
|
# Here we're trying to stay compatible with openssl 1.0.* and 1.1.*. Some
|
||||||
else: result = TLSv1_method()
|
# symbols are loaded dynamically and we don't use them if not found.
|
||||||
|
proc thisModule(): LibHandle {.inline.} =
|
||||||
|
var thisMod {.global.}: LibHandle
|
||||||
|
if thisMod.isNil: thisMod = loadLib()
|
||||||
|
result = thisMod
|
||||||
|
|
||||||
proc SSLv3_method*(): PSSL_METHOD {.deprecated.} =
|
proc sslModule(): LibHandle {.inline.} =
|
||||||
let theProc = cast[proc(): PSSL_METHOD {.cdecl, gcsafe.}](sslSym("SSLv3_method"))
|
var sslMod {.global.}: LibHandle
|
||||||
if not theProc.isNil: result = theProc()
|
if sslMod.isNil: sslMod = loadLibPattern(DLLSSLName)
|
||||||
else: result = TLSv1_method()
|
result = sslMod
|
||||||
|
|
||||||
|
proc sslSym(name: string): pointer =
|
||||||
|
var dl = thisModule()
|
||||||
|
if not dl.isNil:
|
||||||
|
result = symAddr(dl, name)
|
||||||
|
if result.isNil:
|
||||||
|
dl = sslModule()
|
||||||
|
if not dl.isNil:
|
||||||
|
result = symAddr(dl, name)
|
||||||
|
|
||||||
|
proc SSL_library_init*(): cint {.discardable.} =
|
||||||
|
let theProc = cast[proc(): cint {.cdecl.}](sslSym("SSL_library_init"))
|
||||||
|
if not theProc.isNil: result = theProc()
|
||||||
|
|
||||||
|
proc SSL_load_error_strings*() =
|
||||||
|
let theProc = cast[proc() {.cdecl.}](sslSym("SSL_load_error_strings"))
|
||||||
|
if not theProc.isNil: theProc()
|
||||||
|
|
||||||
|
proc SSLv23_client_method*(): PSSL_METHOD =
|
||||||
|
let theProc = cast[proc(): PSSL_METHOD {.cdecl, gcsafe.}](sslSym("SSLv23_client_method"))
|
||||||
|
if not theProc.isNil: result = theProc()
|
||||||
|
else: result = TLSv1_method()
|
||||||
|
|
||||||
|
proc SSLv23_method*(): PSSL_METHOD =
|
||||||
|
let theProc = cast[proc(): PSSL_METHOD {.cdecl, gcsafe.}](sslSym("SSLv23_method"))
|
||||||
|
if not theProc.isNil: result = theProc()
|
||||||
|
else: result = TLSv1_method()
|
||||||
|
|
||||||
|
proc SSLv2_method*(): PSSL_METHOD =
|
||||||
|
let theProc = cast[proc(): PSSL_METHOD {.cdecl, gcsafe.}](sslSym("SSLv2_method"))
|
||||||
|
if not theProc.isNil: result = theProc()
|
||||||
|
else: result = TLSv1_method()
|
||||||
|
|
||||||
|
proc SSLv3_method*(): PSSL_METHOD =
|
||||||
|
let theProc = cast[proc(): PSSL_METHOD {.cdecl, gcsafe.}](sslSym("SSLv3_method"))
|
||||||
|
if not theProc.isNil: result = theProc()
|
||||||
|
else: result = TLSv1_method()
|
||||||
|
|
||||||
|
proc OpenSSL_add_all_algorithms*() =
|
||||||
|
let theProc = cast[proc() {.cdecl.}](sslSym("OPENSSL_add_all_algorithms_conf"))
|
||||||
|
if not theProc.isNil: theProc()
|
||||||
|
|
||||||
|
proc ERR_load_BIO_strings*(){.cdecl, dynlib: DLLUtilName, importc.}
|
||||||
|
|
||||||
proc SSL_new*(context: SslCtx): SslPtr{.cdecl, dynlib: DLLSSLName, importc.}
|
proc SSL_new*(context: SslCtx): SslPtr{.cdecl, dynlib: DLLSSLName, importc.}
|
||||||
proc SSL_free*(ssl: SslPtr){.cdecl, dynlib: DLLSSLName, importc.}
|
proc SSL_free*(ssl: SslPtr){.cdecl, dynlib: DLLSSLName, importc.}
|
||||||
|
|
@ -306,10 +321,6 @@ proc ERR_error_string*(e: cInt, buf: cstring): cstring{.cdecl,
|
||||||
proc ERR_get_error*(): cInt{.cdecl, dynlib: DLLUtilName, importc.}
|
proc ERR_get_error*(): cInt{.cdecl, dynlib: DLLUtilName, importc.}
|
||||||
proc ERR_peek_last_error*(): cInt{.cdecl, dynlib: DLLUtilName, importc.}
|
proc ERR_peek_last_error*(): cInt{.cdecl, dynlib: DLLUtilName, importc.}
|
||||||
|
|
||||||
proc OpenSSL_add_all_algorithms*() =
|
|
||||||
let theProc = cast[proc() {.cdecl.}](sslSym("OPENSSL_add_all_algorithms_conf"))
|
|
||||||
if not theProc.isNil: theProc()
|
|
||||||
|
|
||||||
proc OPENSSL_config*(configName: cstring){.cdecl, dynlib: DLLSSLName, importc.}
|
proc OPENSSL_config*(configName: cstring){.cdecl, dynlib: DLLSSLName, importc.}
|
||||||
|
|
||||||
when not useWinVersion and not defined(macosx) and not defined(android):
|
when not useWinVersion and not defined(macosx) and not defined(android):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue