#1 2024-06-19 06:04:55

Mo0211
Member
Registered: 2018-12-30
Posts: 20

undefined declare with mormot openssl

Hi All,

i have a quick code example and i don't know why this is not working.
This seems to be a reayll beginner issue, but maybe you can support:

https://pastebin.com/1xk7Q2Ck

i included mormot2 in the search clauses, but when accessing the functions from mormot i get an error:

[dcc32 Fehler] Project1.dpr(16): E2003 Undeklarierter Bezeichner: 'OpenSslIsAvailable'
[dcc32 Fehler] Project1.dpr(19): E2003 Undeklarierter Bezeichner: 'OpenSslVersion'

Can you give me an advice why?

Thanks for your support!

Offline

#2 2024-06-19 07:47:18

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,335
Website

Re: undefined declare with mormot openssl

On Windows, you need to explicitly enable OpenSSL linking by setting the USE_OPENSSL conditional for your whole project.
Then mormot.lib.openssl.pas will link the OpenSSL code.

I have modified the source code comments to make it more obvious.
https://github.com/synopse/mORMot2/commit/51f60003

Offline

#3 2024-06-19 14:58:05

Mo0211
Member
Registered: 2018-12-30
Posts: 20

Re: undefined declare with mormot openssl

Hello ab,

really thanks for your quick answer!
it works now smile

When spending more time with your openssl library i searched for a possibility to get the full openssl version as here:

https://www.openssl.org/docs/man3.1/man … _TEXT.html

Currently i have the possibility to use OPENSSL_VERSION_NUM, but i'm not sure if there is a need to convert this to a full version string or if there is another option?

Offline

#4 2024-06-19 16:10:58

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,335
Website

Re: undefined declare with mormot openssl

Currently, you only have OpenSslVersion and OpenSslVersionHexa globals, once the library is loaded

I have added OpenSslVersionText global variable to help:
https://github.com/synopse/mORMot2/commit/82660824

Offline

#5 2024-06-22 21:48:17

Mo0211
Member
Registered: 2018-12-30
Posts: 20

Re: undefined declare with mormot openssl

Hello AB,

oh shit - what a great support!
Really appreciate your help!
i used your changes to add some other functions which are used by me and are relevant to migrate my app to mormot openssl library.
I think my changes are not 100% perfect, but can i send you my functions and is it possible to add them?
Upgrades in the future would then be easier for me.

Thanks for your support!

Offline

#6 2024-06-23 10:32:55

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,335
Website

Re: undefined declare with mormot openssl

You can make a Pull Request on github: we will review and include it.

Thanks for your feedback!

Offline

#7 2024-06-27 07:27:50

Mo0211
Member
Registered: 2018-12-30
Posts: 20

Re: undefined declare with mormot openssl

Hi Ab,

thank you for the possibility - will do!
But one more questions regarding the implementation:
I have one function and added this one as you did - but the difference is, that this function is new and only available in openssl 3.0.
This leads to errors when using a version beyond.
Is there a conditional loading possible (when loading openssl3XX then load this function else not?)

Really appreciate your answer!

Thanks!

Offline

#8 2024-06-27 07:42:11

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,335
Website

Re: undefined declare with mormot openssl

In the LIB_*ENTRIES[] name lists, you can just put a ? before the name, and it won't fail if this function is not available.

Then you will have to use "if not Assigned(...) then" pattern like in the following wrapper function:

function EVP_DigestSign(ctx: PEVP_MD_CTX; sigret: PByte; var siglen: PtrUInt;
   tbs: PByte; tbslen: PtrUInt): integer;
begin
  if Assigned(libcrypto.EVP_DigestSign) then
    // new 1.1/3.x API - as required e.g. by ED25519
    result := libcrypto.EVP_DigestSign(ctx, sigret, siglen, tbs, tbslen)
  else
  begin
    // fallback for oldest OpenSSL versions
    if sigret = nil then

Offline

Board footer

Powered by FluxBB