# When playing in the editor WebSocket connection successful but failed when playing in packaged, why?

**URL:** <https://forums.unrealengine.com/t/when-playing-in-the-editor-websocket-connection-successful-but-failed-when-playing-in-packaged-why/436199>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [October 23, 2018, 1:18pm UTC](https://forums.unrealengine.com/t/when-playing-in-the-editor-websocket-connection-successful-but-failed-when-playing-in-packaged-why/436199 "2018-10-23T13:18:45Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Engineer](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Engineer](https://forums.unrealengine.com/u/Engineer)\
**Post date:** [October 23, 2018, 1:18pm UTC](https://forums.unrealengine.com/t/when-playing-in-the-editor-websocket-connection-successful-but-failed-when-playing-in-packaged-why/436199/1 "2018-10-23T13:18:45Z")

</div>

When playing in the editor WebSocket (from Runtime/Online/WebSocket) connection was successful but failed when playing in packaged project. Why? UE4 versions used were 4.18 and 4.19. Platform is Windows x64.

Here’s the log.

```
[2018.10.23-08.55.37:666][308]LogTemp: Display: Connecting to wss://localhost/lobby/
[2018.10.23-08.55.38:397][350]LogWebSockets: Warning: Lws(Error): server's cert didn't look good, X509_V_ERR = 20: error:00000014:lib(0):func(0):SSL lib
[2018.10.23-08.55.38:431][352]LogWebSockets: Warning: Lws(Error): server's cert didn't look good, X509_V_ERR = 20: error:00000014:lib(0):func(0):SSL lib
[2018.10.23-08.55.38:443][352]LogTemp: Display: Error connecting: Connection timed out

```

Upon closer examination, the UE4’s WebSocket library uses Libwebsocket and OpenSSL, and that `X509_V_ERR = 20` means `X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY`. [See here.](https://github.com/openssl/openssl/blob/master/include/openssl/x509_vfy.h#L119) But I’m sure the certificate is valid, and not self-signed. Can anyone help? Again note that the connection works in the editor but not in packaged project. I’m not sure why.

In 4.20 the log is like this

```
[2018.10.23-13.28.59:390][399]LogTemp: Display: Connecting to wss://localhost/lobby/
[2018.10.23-13.29.00:119][446]LogWebSockets: Warning: Lws(Error): SSL error: unable to get local issuer certificate (preverify_ok=0;err=20;depth=3)
[2018.10.23-13.29.00:121][446]LogWebSockets: Warning: Lws(Error): SSL connect error 336134278: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed
[2018.10.23-13.29.00:122][446]LogTemp: Display: Error connecting: lws_ssl_client_connect2 failed

```

Basically the same error, but more verbose.

---

<div class="post-metadata">

**Author:** ![Engineer](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Engineer](https://forums.unrealengine.com/u/Engineer)\
**Post date:** [October 24, 2018, 2:06pm UTC](https://forums.unrealengine.com/t/when-playing-in-the-editor-websocket-connection-successful-but-failed-when-playing-in-packaged-why/436199/2 "2018-10-24T14:06:00Z")

</div>

Sigh, turns out UE4 doesn’t automatically copy the certificate file into pak file. Also the SSL module really lacks documentation, but I figured it all out eventually. [ISslCertificateManager::AddCertificatesToSslContext | Unreal Engine Documentation](https://api.unrealengine.com/INT/API/Runtime/SSL/Interfaces/ISslCertificateManager/AddCertificatesToSslContext/index.html)

---

<div class="post-metadata">

**Author:** ![neVeRmind8837](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@neVeRmind8837](https://forums.unrealengine.com/u/neVeRmind8837)\
**Post date:** [June 4, 2019, 12:24pm UTC](https://forums.unrealengine.com/t/when-playing-in-the-editor-websocket-connection-successful-but-failed-when-playing-in-packaged-why/436199/3 "2019-06-04T12:24:16Z")

</div>

So how did you solve this? I have the same problem but I´m not a programmer. Feeling a bit lost with this documentation

---

<div class="post-metadata">

**Author:** ![TripleSMG](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TripleSMG](https://forums.unrealengine.com/u/TripleSMG)\
**Post date:** [September 9, 2020, 4:24pm UTC](https://forums.unrealengine.com/t/when-playing-in-the-editor-websocket-connection-successful-but-failed-when-playing-in-packaged-why/436199/4 "2020-09-09T16:24:31Z")

</div>

Something else to check depending on the platform you’re targeting, make sure that platform is setting WITH\_SSL to 1 and including the necessary include paths and third party libraries in SSL.Build.cs. Otherwise, code that you’ll need will not be included in your build causing all sorts of issues.

If your platform isn’t listed in SSL.Build.cs,you’ll need to add a new line like so:

```
Target.Platform == UnrealTargetPlatform.YourNewPlatform

```

Good luck!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_51938974](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_51938974](https://forums.unrealengine.com/u/anonymous_user_51938974)\
**Post date:** [December 23, 2020, 4:22am UTC](https://forums.unrealengine.com/t/when-playing-in-the-editor-websocket-connection-successful-but-failed-when-playing-in-packaged-why/436199/5 "2020-12-23T04:22:42Z")

</div>

Yes, I’m having this exact issue, would be nice if the actual answer was mentioned instead of “I just figured it out eventually” with a link to raw documentation.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_51938974](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_51938974](https://forums.unrealengine.com/u/anonymous_user_51938974)\
**Post date:** [December 23, 2020, 5:14pm UTC](https://forums.unrealengine.com/t/when-playing-in-the-editor-websocket-connection-successful-but-failed-when-playing-in-packaged-why/436199/6 "2020-12-23T17:14:23Z")

</div>

I experienced the same issue when packaging on Mac - I resolved it by adding the default cacerts.pem key that comes with UE4’s source to Project Settings \> Packaging \> Packaging \> Additional Non-Assets Directories to Copy

---

<div class="post-metadata">

**Author:** ![PolygonArt\_WEN](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@PolygonArt\_WEN](https://forums.unrealengine.com/u/PolygonArt_WEN)\
**Post date:** [June 14, 2021, 1:36pm UTC](https://forums.unrealengine.com/t/when-playing-in-the-editor-websocket-connection-successful-but-failed-when-playing-in-packaged-why/436199/7 "2021-06-14T13:36:31Z")

</div>

Where is the cacerts.pem located. There is non to be found for me.

---

<div class="post-metadata">

**Author:** ![PhilSorger](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/philsorger/32/592330_2.png) [@PhilSorger](https://forums.unrealengine.com/u/PhilSorger)\
**Post date:** [July 12, 2021, 11:06pm UTC](https://forums.unrealengine.com/t/when-playing-in-the-editor-websocket-connection-successful-but-failed-when-playing-in-packaged-why/436199/8 "2021-07-12T23:06:53Z")

</div>

ok so the cacert.pem is found in Engine/Content/Certificates/ThirdParty/cacert.pem  
and i copy that to my Content/Certificates folder  
and i’m trying to add an additional non-asset directory to the package (by changing Config/DefaultGame.ini)  
+DirectoriesToAlwaysStageAsNonUFS=(Path=“Certificates”)  
but i still get an error:  
[2021.07.12-23.02.20:135][217]LogWebSockets: Warning: Lws(Error): SSL\_new failed: error:00000063:lib(0):func(0):reason(99)

---

<div class="post-metadata">

**Author:** ![ff1450sb](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ff1450sb](https://forums.unrealengine.com/u/ff1450sb)\
**Post date:** [July 19, 2021, 6:08am UTC](https://forums.unrealengine.com/t/when-playing-in-the-editor-websocket-connection-successful-but-failed-when-playing-in-packaged-why/436199/9 "2021-07-19T06:08:31Z")

</div>

I resolved the problem by the same way but I set the “Additional Non-Assets Directories to Copy” value from the Editor menu.

---

<div class="post-metadata">

**Author:** ![heivoll](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@heivoll](https://forums.unrealengine.com/u/heivoll)\
**Post date:** [October 12, 2021, 1:05am UTC](https://forums.unrealengine.com/t/when-playing-in-the-editor-websocket-connection-successful-but-failed-when-playing-in-packaged-why/436199/10 "2021-10-12T01:05:20Z")

</div>

For anyone else looking, VE1977’s comment below solves it. The exact steps to fix it is:

1. Copy [Engine directory]/Engine/Content/Certificates/ThirdParty/cacert.pem to [Project directory]/Content/Certificates/cacert.pem
2. In your project settings, under Packaging, add an array item to “Additional Non-Asset Directories to Package”, with the value Certifications

That’s it, no need to do anything in C++. You may need to copy this again when you update engine version.

---

<div class="post-metadata">

**Author:** ![panjianxing](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@panjianxing](https://forums.unrealengine.com/u/panjianxing)\
**Post date:** [March 10, 2022, 4:15pm UTC](https://forums.unrealengine.com/t/when-playing-in-the-editor-websocket-connection-successful-but-failed-when-playing-in-packaged-why/436199/11 "2022-03-10T16:15:49Z")

</div>

Hello, I operated according to the method you used, but I can’t link after packaging

---

<div class="post-metadata">

**Author:** ![heivoll](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@heivoll](https://forums.unrealengine.com/u/heivoll)\
**Post date:** [March 10, 2022, 5:51pm UTC](https://forums.unrealengine.com/t/when-playing-in-the-editor-websocket-connection-successful-but-failed-when-playing-in-packaged-why/436199/12 "2022-03-10T17:51:10Z")

</div>

Bah, I see I have a typo in my post here. The value to put in the config should be Certificates (the same as the folder you created). Does fixing that help? If not, what kind of errors are you getting?

---

<div class="post-metadata">

**Author:** ![panjianxing](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@panjianxing](https://forums.unrealengine.com/u/panjianxing)\
**Post date:** [March 11, 2022, 7:55am UTC](https://forums.unrealengine.com/t/when-playing-in-the-editor-websocket-connection-successful-but-failed-when-playing-in-packaged-why/436199/13 "2022-03-11T07:55:54Z")

</div>

Still can’t ~ ~ it’s available in editing status, but after it’s packaged, it can’t link websockt

---

<div class="post-metadata">

**Author:** ![S\_Q\_R](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@S\_Q\_R](https://forums.unrealengine.com/u/S_Q_R)\
**Post date:** [March 19, 2023, 3:19pm UTC](https://forums.unrealengine.com/t/when-playing-in-the-editor-websocket-connection-successful-but-failed-when-playing-in-packaged-why/436199/14 "2023-03-19T15:19:35Z")

</div>

Hi. Suggested solution does not work on my PC. Do anyone know if there is any other way of fixing certificate? And just to be sure. Does this fix also helps with editor behaviour or its only for packaged build? Thanks!

EDIT:  
Found this forum entry. This one helped me so if coping certifcates does not work for you [here](https://forums.unrealengine.com/t/http-requests-not-working-in-plugin/446775/13) is different solution to try

---

<div class="post-metadata">

**Author:** ![heivoll](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@heivoll](https://forums.unrealengine.com/u/heivoll)\
**Post date:** [March 24, 2023, 11:49am UTC](https://forums.unrealengine.com/t/when-playing-in-the-editor-websocket-connection-successful-but-failed-when-playing-in-packaged-why/436199/15 "2023-03-24T11:49:31Z")

</div>

Hi. We got something similar to this on one of the machines at our company. For that specific one, all HTTP requests were blocked by one request failing; more specifically, the usage tracking request of the ExpressiveText plugin. So it’s worth checking the logs and looking for warnings about the HTTP module processing requests. Disabling the plugin worked.

---

<div class="post-metadata">

**Author:** ![lehuan5062](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@lehuan5062](https://forums.unrealengine.com/u/lehuan5062)\
**Post date:** [August 23, 2023, 8:37am UTC](https://forums.unrealengine.com/t/when-playing-in-the-editor-websocket-connection-successful-but-failed-when-playing-in-packaged-why/436199/16 "2023-08-23T08:37:37Z")

</div>

I have the “SSL error: unable to get local issuer certificate (preverify\_ok=0;err=20;depth=0)”, but when playing in editor.

---

<div class="post-metadata">

**Author:** ![eggapple1220](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@eggapple1220](https://forums.unrealengine.com/u/eggapple1220)\
**Post date:** [January 23, 2024, 1:21pm UTC](https://forums.unrealengine.com/t/when-playing-in-the-editor-websocket-connection-successful-but-failed-when-playing-in-packaged-why/436199/17 "2024-01-23T13:21:52Z")

</div>

1. copy cacert.pem to [unrealProject]/Content/Certificates
2. project setting \> packaging \> Additional Non-Asset Directories to Package \> add item “Certificates”

it works ~

my env  
unreal version = 5.0.3  
use webSocket ( c++ )  
win or mac no issue  
but packaging ios has issue  
issue = LogWebSockets: Warning: Lws(Error): SSL error: unable to get local issuer certificate (preverify\_ok=0;err=20;depth=2)

---

<div class="post-metadata">

**Author:** ![chevyhuang](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@chevyhuang](https://forums.unrealengine.com/u/chevyhuang)\
**Post date:** [June 27, 2024, 3:34am UTC](https://forums.unrealengine.com/t/when-playing-in-the-editor-websocket-connection-successful-but-failed-when-playing-in-packaged-why/436199/18 "2024-06-27T03:34:12Z")

</div>

可以在DefaultEngine.ini中添加：  
[LwsWebSocket]  
bDisableCertValidation=True

---

<div class="post-metadata">

**Author:** ![zhaojunmeng](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@zhaojunmeng](https://forums.unrealengine.com/u/zhaojunmeng)\
**Post date:** [July 2, 2024, 12:45pm UTC](https://forums.unrealengine.com/t/when-playing-in-the-editor-websocket-connection-successful-but-failed-when-playing-in-packaged-why/436199/19 "2024-07-02T12:45:56Z")

</div>

# Solution:

Just add the follow setting in DefaultEngine.ini, and when packaging the game, the cacert.pem file will be staged automatically.

```auto
[/Script/Engine.NetworkSettings]
n.VerifyPeer=True

```

The logic is in /Engine/Source/Programs/AutomationTool/Scripts  
/CopyBuildToStagingDirectory.Automation.cs:  
[https://github.com/EpicGames/UnrealEngine/blob/11ea386451b0beaff2ab34ad3d222def138fcd29/Engine/Source/Programs/AutomationTool/Scripts/CopyBuildToStagingDirectory.Automation.cs#L1204](https://github.com/EpicGames/UnrealEngine/blob/11ea386451b0beaff2ab34ad3d222def138fcd29/Engine/Source/Programs/AutomationTool/Scripts/CopyBuildToStagingDirectory.Automation.cs#L1204)

# Why it’s working in editor?

In FSslCertificateManager::BuildRootCertificateArray(), CertificateBundlePath is searched in in the order of ProjectContentDir, EngineContentDir. In editor, EngineContentDir alwarys has the Certificates/ThirdParty/cacert.pem file, so it’s working in editor.  
[https://github.com/EpicGames/UnrealEngine/blob/c830445187784f1269f43b56f095493a27d5a636/Engine/Source/Runtime/Online/SSL/Private/SslCertificateManager.cpp#L337](https://github.com/EpicGames/UnrealEngine/blob/c830445187784f1269f43b56f095493a27d5a636/Engine/Source/Runtime/Online/SSL/Private/SslCertificateManager.cpp#L337)

# How to check it’s really working

On Windows, you can delete all entries in HKEY\_LOCAL\_MACHINE\SOFTWARE\Microsoft\SystemCertificates\AuthRoot\Certificates\ in regedit, and see if the packaged game really using the cacert.pem file(and not using the system cached one).

---

<div class="post-metadata">

**Author:** ![IMPrloggini](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@IMPrloggini](https://forums.unrealengine.com/u/IMPrloggini)\
**Post date:** [July 11, 2024, 1:15pm UTC](https://forums.unrealengine.com/t/when-playing-in-the-editor-websocket-connection-successful-but-failed-when-playing-in-packaged-why/436199/20 "2024-07-11T13:15:37Z")

</div>

I just want to say thank you for this thread, it saved us A LOT of time!  
We had issues with a third party plugin not able to perform SSL verification on cooked builds on MacOS and UE 5.3.  
The solution for us was settings those certificates as RuntimeDependencies for the plugin, so after cook, those non USF files will be staged with the build.  
That being said, the other mentioned solutions can possibly work as well.

[Next page](https://forums.unrealengine.com/t/when-playing-in-the-editor-websocket-connection-successful-but-failed-when-playing-in-packaged-why/436199.md?page=2)
