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.
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. 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
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:
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.
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
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)
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?
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 is different solution to try
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.
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)
On Winddows, 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).
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.