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 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))
{
UE_LOG(LogPS_AI_ConvAgent, Log, TEXT("SSL cacert.pem found at: %s"), *ProjectCertPath);
return;
}
#if PLATFORM_ANDROID
// On Android, ProjectContentDir lives inside the APK (read-only).
// Use ProjectSavedDir as a writable fallback for the cert copy.
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.
// Try to auto-copy from the plugin's Resources directory to Content/Certificates/.
// In packaged builds, Content/Certificates/ must be staged via
// DirectoriesToAlwaysStageAsNonUFS in DefaultGame.ini.
TSharedPtr<IPlugin> Plugin = IPluginManager::Get().FindPlugin(TEXT("PS_AI_ConvAgent"));
if (Plugin.IsValid())
{
@ -79,10 +68,10 @@ void FPS_AI_ConvAgentModule::EnsureSSLCertificates()
if (FPlatformFileManager::Get().GetPlatformFile().FileExists(*PluginCertPath))
{
FPlatformFileManager::Get().GetPlatformFile().CreateDirectoryTree(
*FPaths::GetPath(CopyDestPath));
if (FPlatformFileManager::Get().GetPlatformFile().CopyFile(*CopyDestPath, *PluginCertPath))
*FPaths::GetPath(ProjectCertPath));
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;
}
}