Revert SSL cert path to Content/Certificates for packaged build staging

Saved/ is not staged in packaged builds, so Content/Certificates/ is the
only reliable location. Simplified code by removing Android-specific
writable fallback (Content/ works on all platforms with NonUFS staging).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
j.foucher 2026-03-01 16:42:16 +01:00
parent 33ec54150f
commit 275065f5aa

View File

@ -49,27 +49,16 @@ void FPS_AI_ConvAgentModule::EnsureSSLCertificates()
const FString CertRelPath = FString(TEXT("Certificates")) / TEXT("cacert.pem"); const FString CertRelPath = FString(TEXT("Certificates")) / TEXT("cacert.pem");
const FString ProjectCertPath = FPaths::ProjectContentDir() / CertRelPath; const FString ProjectCertPath = FPaths::ProjectContentDir() / CertRelPath;
// Check standard location (works on all platforms, including Android if cert was staged). // Check if cert already exists in Content/Certificates/.
if (FPlatformFileManager::Get().GetPlatformFile().FileExists(*ProjectCertPath)) if (FPlatformFileManager::Get().GetPlatformFile().FileExists(*ProjectCertPath))
{ {
UE_LOG(LogPS_AI_ConvAgent, Log, TEXT("SSL cacert.pem found at: %s"), *ProjectCertPath); UE_LOG(LogPS_AI_ConvAgent, Log, TEXT("SSL cacert.pem found at: %s"), *ProjectCertPath);
return; return;
} }
#if PLATFORM_ANDROID // Try to auto-copy from the plugin's Resources directory to Content/Certificates/.
// On Android, ProjectContentDir lives inside the APK (read-only). // In packaged builds, Content/Certificates/ must be staged via
// Use ProjectSavedDir as a writable fallback for the cert copy. // DirectoriesToAlwaysStageAsNonUFS in DefaultGame.ini.
const FString CopyDestPath = FPaths::ProjectSavedDir() / CertRelPath;
if (FPlatformFileManager::Get().GetPlatformFile().FileExists(*CopyDestPath))
{
UE_LOG(LogPS_AI_ConvAgent, Log, TEXT("SSL cacert.pem found at: %s"), *CopyDestPath);
return;
}
#else
const FString CopyDestPath = ProjectCertPath;
#endif
// Try to auto-copy from the plugin's Resources directory.
TSharedPtr<IPlugin> Plugin = IPluginManager::Get().FindPlugin(TEXT("PS_AI_ConvAgent")); TSharedPtr<IPlugin> Plugin = IPluginManager::Get().FindPlugin(TEXT("PS_AI_ConvAgent"));
if (Plugin.IsValid()) if (Plugin.IsValid())
{ {
@ -79,10 +68,10 @@ void FPS_AI_ConvAgentModule::EnsureSSLCertificates()
if (FPlatformFileManager::Get().GetPlatformFile().FileExists(*PluginCertPath)) if (FPlatformFileManager::Get().GetPlatformFile().FileExists(*PluginCertPath))
{ {
FPlatformFileManager::Get().GetPlatformFile().CreateDirectoryTree( FPlatformFileManager::Get().GetPlatformFile().CreateDirectoryTree(
*FPaths::GetPath(CopyDestPath)); *FPaths::GetPath(ProjectCertPath));
if (FPlatformFileManager::Get().GetPlatformFile().CopyFile(*CopyDestPath, *PluginCertPath)) if (FPlatformFileManager::Get().GetPlatformFile().CopyFile(*ProjectCertPath, *PluginCertPath))
{ {
UE_LOG(LogPS_AI_ConvAgent, Log, TEXT("Copied SSL cacert.pem from plugin to: %s"), *CopyDestPath); UE_LOG(LogPS_AI_ConvAgent, Log, TEXT("Copied SSL cacert.pem from plugin to: %s"), *ProjectCertPath);
return; return;
} }
} }