Skip to content

Commit

Permalink
Update jwt.nim
Browse files Browse the repository at this point in the history
  • Loading branch information
h3rald authored Jan 7, 2024
1 parent 75dbcbd commit 6617314
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/litestorepkg/lib/jwt.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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")

Expand All @@ -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:
Expand Down

0 comments on commit 6617314

Please sign in to comment.