• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Cambesa · Dec 21, 2017 at 01:08 PM · dllsecuritydllnotfoundexceptionencryptionencrypt

OpenSSL-net DllNotFoundException: Assets/Plugins/OpenSSL/libeay32.dll

I am trying to use OpenSSL.net in Unity. I've cloned the git repository, build an AnyCPU release built in visual studio which made a directory containing: libeay32.dll, ManagedOpenSsl.dll and ssleay32.dll. I've dragged them in my project in Assets\Plugins\OpenSSL and I can now access OpenSSL from script:
using OpenSSL.Crypto;
I'm using a small script to try and use OpenSSL functionality:

 byte[] Encrypt(byte[] bytes)
     {
         using (CipherContext cc = new CipherContext(Cipher.AES_256_CBC))
         {
             return cc.Encrypt(bytes, testKey, testIV);
         }
     }

When I run the method, I get an error in the unity console:

DllNotFoundException: Assets/Plugins/OpenSSL/libeay32.dll
OpenSSL.Core.Version.get_Library ()
OpenSSL.Core.Native..cctor ()
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for OpenSSL.Core.Native
OpenSSL.Crypto.Cipher..cctor ()
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for OpenSSL.Crypto.Cipher
TestSerialization.Update () (at Assets/Scripts/SerializedClasses/TestSerialization.cs:51)

On line 51, the encrypt method is called. I'm targeting Android and in a later stage IOS but it seems to not even work on Windows 10.

Can someone tell me how this happens?

Kind regards,

Yorick

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Cambesa · Dec 22, 2017 at 02:49 PM

Solved by switching to this OpenSSL.net repository which is a wrapper written in C# targeting the .NET Framework 3.5.

When you clone the repository(using SourceTree or Tortoise Git or any program of your choice), you will find a folder called native containing Windows dll builds for 32bit and 64bit. Drop the 32bit libeay32.dll and ssleay32.dll in the unity folder: \Assets\Plugins\x86 and drop the 64bit libeay32.dll and ssleay32.dll in \Assets\Plugins\x86_64.

When that's done open the ManagedOpenSsl-VS2015.sln in Visual Studio (2017). Build the project and navigate to the bin folder which is in the same folder as the .sln. Go in the Debug folder and copy the ManagedOpenSsl.dll and drop it in \Assets\Plugins. You should now be able to access OpenSSL by writing any of these usings:
using OpenSSL;
using OpenSSL.Core;
using OpenSSL.Crypto;
using OpenSSL.Exceptions;
using OpenSSL.Extensions;
using OpenSSL.SSL;
using OpenSSL.X509;
using OpenSSL.Crypto.EC;

Kind regards,

Yorick

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

Answer by remy_rm · Feb 27, 2018 at 10:08 AM

if you still get an error saying DllNotFoundException: libeay32 Then you might have to install openSSL from https://slproweb.com/products/Win32OpenSSL.html

I also had to add OpenSSL to my paths > Enviroment variables ( ";C:\OpenSSL-Win64\bin")

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

73 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Every time I re-open Unity, I have to rebuild one of my external DLLs -1 Answers

Failed to load dll error 3 Answers

MIdiJack DLL not found 0 Answers

Saftey on Unity Servers 0 Answers

use [DllImport("xxxx")] for .so with other .so 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges