How to use included OpenSSL

I’m trying to use the OpenSSL library included with the engine.

I am using 4.25

In my searches I see people saying to add OpenSSl as a dependency to my project’s build file.

I have seen couple different lines to add to the build file, every one of them causes errors - usually about the the function not being in the current context.

AddEngineThirdPartyPrivateStaticDependencies(Target, “OpenSSL”);

is one example - I believe I read some where to try

ExtraModuleNames.AddRange( new string[] { “OpenSSL”} ); - but that came back with OpenSSL not being a c++ module.

I can include openSSL if I do the full path to the header, but then any includes in that header fail.

So far only by adding the folder “E:\UE_4.25\Engine\Source\ThirdParty\OpenSSL\1.1.1\Include\Win64\VS2015” to the visual studio c/c++ directory includes list can I just do a regular "#include “openssl/sha.h”.

But that doesn’t feel right.

In the solution explorer, I can see the openssl folder under UE4\Source\ThirdParty\openssl - but none of the different openssl version show up and none of the source code files.

All the ThirdParty libraries just contain one or more build files, or files with a .tps extension.

I’m trying to access openSSL’s sha-256.

I don’t want to just use a 3rd party implementation as the one I found was slow compared to openssl’s (I tested in a separate test application).

Any help would be greatly appreciated - thanks

My problem is that I kept trying to do things in the target file, not the build file - For some reason it just never clicked that I was in the wrong file.

To enable OpenSSL in an unreal c++ project (I’m using Visual Studio):

Open up your project build file.

Add OpenSSL to the PublicDependencyModuleNames:

using UnrealBuildTool;

public class MyProject : ModuleRules
{
    public MyProject(ReadOnlyTargetRules Target) : base(Target)
    {
         PublicDependencyModuleNames.AddRange(new string[] {
        "PhysicsCore",
        "OpenSSL"
        });
    }
}

Close your solution, right click your unreal project .uproject file and choose “Generate Project Files”.

Where you want to use openSSL add at the top of your code file in the includes section or in your header file. (in my case I’m using evp as the docs say for sha256).

#define UI UI_ST
THIRD_PARTY_INCLUDES_START
#include "openssl/evp.h"
THIRD_PARTY_INCLUDES_END
#undef UI
3 Likes