From 83bbece88b1695abf93747848109f98485d34341 Mon Sep 17 00:00:00 2001 From: Fabio Cevasco Date: Sun, 7 Jan 2024 12:10:23 +0100 Subject: [PATCH 1/5] Update jwt.nim --- src/litestorepkg/lib/jwt.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/litestorepkg/lib/jwt.nim b/src/litestorepkg/lib/jwt.nim index 6db51e1..eb7d76c 100644 --- a/src/litestorepkg/lib/jwt.nim +++ b/src/litestorepkg/lib/jwt.nim @@ -4,7 +4,7 @@ import std/[ import types when defined(windows) and defined(amd64): - {.passL: "-static -L"&getProjectPath()&"/litestorepkg/vendor/openssl/windows -lssl -lcrypto -lbcrypt".} + {.passL: "-static -L"&getProjectPath()&"/litestorepkg/vendor/openssl/windows -lssl -lcrypto -lbcrypt -lws2_32 -lcrypt32".} elif defined(linux) and defined(amd64): {.passL: "-static -L"&getProjectPath()&"/litestorepkg/vendor/openssl/linux -lssl -lcrypto".} elif defined(macosx) and defined(amd64): From 75dbcbd170d2228190f8bd39382284a534f609a5 Mon Sep 17 00:00:00 2001 From: Fabio Cevasco Date: Sun, 7 Jan 2024 14:29:40 +0100 Subject: [PATCH 2/5] Update jwt.nim --- src/litestorepkg/lib/jwt.nim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/litestorepkg/lib/jwt.nim b/src/litestorepkg/lib/jwt.nim index eb7d76c..7ad33d5 100644 --- a/src/litestorepkg/lib/jwt.nim +++ b/src/litestorepkg/lib/jwt.nim @@ -4,7 +4,7 @@ import std/[ import types when defined(windows) and defined(amd64): - {.passL: "-static -L"&getProjectPath()&"/litestorepkg/vendor/openssl/windows -lssl -lcrypto -lbcrypt -lws2_32 -lcrypt32".} + {.passL: "-static -L"&getProjectPath()&"/litestorepkg/vendor/openssl/windows -lssl -lcrypto -lbcrypt -lws2_32 -lcrypt32 -ltimezone".} elif defined(linux) and defined(amd64): {.passL: "-static -L"&getProjectPath()&"/litestorepkg/vendor/openssl/linux -lssl -lcrypto".} elif defined(macosx) and defined(amd64): @@ -14,6 +14,8 @@ elif defined(macosx) and defined(amd64): proc EVP_PKEY_new(): EVP_PKEY {.cdecl, importc.} proc X509_get_pubkey(cert: PX509): EVP_PKEY {.cdecl, importc.} proc X509_free(cert: PX509) {.cdecl, importc.} +proc EVP_MD_CTX_create(): EVP_MD_CTX {.cdecl, importc.} +proc EVP_MD_CTX_destroy(ctx: EVP_MD_CTX) {.cdecl, importc.} proc EVP_DigestVerifyInit(ctx: EVP_MD_CTX; pctx: ptr EVP_PKEY_CTX; typ: EVP_MD; e: ENGINE; pkey: EVP_PKEY): cint {.cdecl, importc.} proc EVP_DigestVerifyUpdate(ctx: EVP_MD_CTX; data: pointer; From 661731431cee0cdeb49f101a71d2078d59d83732 Mon Sep 17 00:00:00 2001 From: Fabio Cevasco Date: Sun, 7 Jan 2024 14:46:00 +0100 Subject: [PATCH 3/5] Update jwt.nim --- src/litestorepkg/lib/jwt.nim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/litestorepkg/lib/jwt.nim b/src/litestorepkg/lib/jwt.nim index 7ad33d5..1d317e9 100644 --- a/src/litestorepkg/lib/jwt.nim +++ b/src/litestorepkg/lib/jwt.nim @@ -14,8 +14,8 @@ elif defined(macosx) and defined(amd64): proc EVP_PKEY_new(): EVP_PKEY {.cdecl, importc.} proc X509_get_pubkey(cert: PX509): EVP_PKEY {.cdecl, importc.} proc X509_free(cert: PX509) {.cdecl, importc.} -proc EVP_MD_CTX_create(): EVP_MD_CTX {.cdecl, importc.} -proc EVP_MD_CTX_destroy(ctx: EVP_MD_CTX) {.cdecl, importc.} +proc EVP_MD_CTX_new(): EVP_MD_CTX {.cdecl, importc.} +proc EVP_MD_CTX_free(ctx: EVP_MD_CTX) {.cdecl, importc.} proc EVP_DigestVerifyInit(ctx: EVP_MD_CTX; pctx: ptr EVP_PKEY_CTX; typ: EVP_MD; e: ENGINE; pkey: EVP_PKEY): cint {.cdecl, importc.} proc EVP_DigestVerifyUpdate(ctx: EVP_MD_CTX; data: pointer; @@ -104,7 +104,7 @@ proc verifySignature*(jwt: JWT; x5c: string) = if pubkey.isNil: raiseX509Error("An error occurred while retrieving the public key") - mdctx = EVP_MD_CTX_create() + mdctx = EVP_MD_CTX_new() if mdctx.isNil: raiseX509Error("Unable to initialize MD CTX") @@ -123,7 +123,7 @@ proc verifySignature*(jwt: JWT; x5c: string) = except CatchableError: let err = getCurrentException() if not mdctx.isNil: - EVP_MD_CTX_destroy(mdctx) + EVP_MD_CTX_free(mdctx) if not pkeyctx.isNil: EVP_PKEY_CTX_free(pkeyctx) if not pubkey.isNil: From 86f2e52f4135d59f95d48937dbd4c7e82fc8694c Mon Sep 17 00:00:00 2001 From: Fabio Cevasco Date: Sun, 7 Jan 2024 15:02:24 +0100 Subject: [PATCH 4/5] Update jwt.nim --- src/litestorepkg/lib/jwt.nim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/litestorepkg/lib/jwt.nim b/src/litestorepkg/lib/jwt.nim index 1d317e9..5a97e44 100644 --- a/src/litestorepkg/lib/jwt.nim +++ b/src/litestorepkg/lib/jwt.nim @@ -4,7 +4,8 @@ import std/[ import types when defined(windows) and defined(amd64): - {.passL: "-static -L"&getProjectPath()&"/litestorepkg/vendor/openssl/windows -lssl -lcrypto -lbcrypt -lws2_32 -lcrypt32 -ltimezone".} + {.emit: """#include """.} + {.passL: "-static -L"&getProjectPath()&"/litestorepkg/vendor/openssl/windows -lssl -lcrypto -lbcrypt -lws2_32 -lcrypt32".} elif defined(linux) and defined(amd64): {.passL: "-static -L"&getProjectPath()&"/litestorepkg/vendor/openssl/linux -lssl -lcrypto".} elif defined(macosx) and defined(amd64): From 01a5d47ae63a6d0e5474874bfec8258f6d6eb67f Mon Sep 17 00:00:00 2001 From: Fabio Cevasco Date: Sun, 7 Jan 2024 15:10:00 +0100 Subject: [PATCH 5/5] Update jwt.nim --- src/litestorepkg/lib/jwt.nim | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/litestorepkg/lib/jwt.nim b/src/litestorepkg/lib/jwt.nim index 5a97e44..8b93e16 100644 --- a/src/litestorepkg/lib/jwt.nim +++ b/src/litestorepkg/lib/jwt.nim @@ -4,8 +4,7 @@ import std/[ import types when defined(windows) and defined(amd64): - {.emit: """#include """.} - {.passL: "-static -L"&getProjectPath()&"/litestorepkg/vendor/openssl/windows -lssl -lcrypto -lbcrypt -lws2_32 -lcrypt32".} + {.passL: "-static -L"&getProjectPath()&"/litestorepkg/vendor/openssl/windows -lssl -lcrypto -lbcrypt -lws2_32 -lcrypt32 -lmsvcrtd".} elif defined(linux) and defined(amd64): {.passL: "-static -L"&getProjectPath()&"/litestorepkg/vendor/openssl/linux -lssl -lcrypto".} elif defined(macosx) and defined(amd64):