JKRhb / dtls2

A DTLS library for Dart based on OpenSSL.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Loading of libssl.so and libcrypto.so fails

Ifilehk opened this issue · comments

Hello there,

First of all thank you for your nice contribution !!!

Was struggling with importing the libraries for and android project in Android Studio but managed to get it work after modifying your code. Strangely your code works for a dart Linux application without modification. Maybe you have an idea why.

For android I had to swap lines in dtls_client.dart this way.
DtlsClient(
this._socket, {
DynamicLibrary? libCrypto, <--- swapped with next
DynamicLibrary? libSsl, <--- swapped
}) : _libCrypto = _loadOpenSsl(libCrypto) ?? lib.libCrypto, <--- swapped with next
_libSsl = _loadOpenSsl(libSsl) ?? lib.libSsl { <--- swapped
_startListening();
}

Thank you, @Ifilehk, for your feedback and for opening this issue! :)

The problems you are facing are in fact a bit strange :/ I can only assume that on Android libcrypto needs to be loaded before libssl for some reason?

What kind of error message do you get without your changes? And do you actually need to swap the order of the parameters to fix it, too? And one last thing: Which OpenSSL version/binaries are you using on Android?

I'll try to replicate the bug on Android over the next few days, lately I've been mostly testing the library on Linux and Windows, therefore Android was a bit of a blank spot. Do you maybe want to create a PR with your changes? :) Or should I just incorporate them?

I took the freedom to already open #46 as a potential fix, can you test if that already works for you? :)

Hello Jan !
No I verified and libcrypto is definitely there. Seems that the order of loading is important. The error message is that libssl need libcrypto what is true so may be loading order, libcrypto before libssl makes the difference.

If I try directly DynamicLibrary.open(libName) in clean Flutter project the loading order doesn't seem to be important.

Now with Linux no more sure about my above mentioned assumption. If important for you could check it again.

Hello Jan ! No I verified and libcrypto is definitely there. Seems that the order of loading is important. The error message is that libssl need libcrypto what is true so may be loading order, libcrypto before libssl makes the difference.

I see, thank you! Then switching the loading order is the way to go :) I would go ahead, merge #46 and then release a new version :)

Now with Linux no more sure about my above mentioned assumption. If important for you could check it again.

I think Linux should be fine, since it is also tested here in the CI :)

Version 0.12.1 has just been released :)

Closing this one as completed for the time being, if you experience any more issues feel free to reopen it :)