mirror of
https://github.com/wiiu-env/AromaUpdater.git
synced 2024-11-23 05:09:20 +01:00
Load embedded cert to allow loading the Updater in Tiramisu
This commit is contained in:
parent
0a09568244
commit
631674686b
6
Makefile
6
Makefile
@ -36,6 +36,7 @@ TARGET := AromaUpdater
|
||||
BUILD := build
|
||||
SOURCES := source \
|
||||
source/utils
|
||||
DATA := data
|
||||
INCLUDES := include
|
||||
CONTENT := data
|
||||
ICON := meta/icon.png
|
||||
@ -184,6 +185,11 @@ $(OFILES_SRC) : $(HFILES_BIN)
|
||||
@echo $(notdir $<)
|
||||
@$(bin2o)
|
||||
|
||||
%.pem.o %_pem.h : %.pem
|
||||
#-------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
@$(bin2o)
|
||||
|
||||
-include $(DEPENDS)
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
@ -21,6 +21,13 @@ ApplicationState::eSubState UpdaterState::UpdateCheckEnvironmentDirectory(Input
|
||||
this->mState = STATE_CHECK_VERSIONS;
|
||||
return SUBSTATE_RUNNING;
|
||||
}
|
||||
|
||||
if (this->mCurEnvironmentPath == DEFAULT_TIRAMISU_ENVIRONMENT_SD_PATH) {
|
||||
mCurEnvironmentPath = DEFAULT_AROMA_ENVIRONMENT_SD_PATH;
|
||||
this->mState = STATE_CHECK_VERSIONS;
|
||||
return SUBSTATE_RUNNING;
|
||||
}
|
||||
|
||||
if (buttonPressed(input, Input::BUTTON_A)) {
|
||||
std::string sNeedle = DEFAULT_AROMA_ENVIRONMENT_PATH;
|
||||
std::string sReplace = this->mCurEnvironmentPath;
|
||||
|
@ -1,15 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#define BACKGROUND_COLOR COLOR_BLACK
|
||||
#define BACKGROUND_COLOR COLOR_BLACK
|
||||
|
||||
#define AROMA_DOWNLOAD_URL "https://aroma.foryour.cafe/"
|
||||
#define UPDATE_SERVER_URL "https://aroma.foryour.cafe"
|
||||
#define CERT_FILE_LOCATION "fs:/vol/content/cacert.pem"
|
||||
#define SD_PATH "fs:/vol/external01/"
|
||||
#define DEFAULT_AROMA_ENVIRONMENT_PATH "wiiu/environments/aroma"
|
||||
#define DEFAULT_AROMA_ENVIRONMENT_SD_PATH SD_PATH DEFAULT_AROMA_ENVIRONMENT_PATH
|
||||
#define UPDATE_OLD_SUFFIX ".update.old"
|
||||
#define UPDATE_TEMP_SUFFIX ".update.temp"
|
||||
#define AROMA_DOWNLOAD_URL "https://aroma.foryour.cafe/"
|
||||
#define UPDATE_SERVER_URL "https://aroma.foryour.cafe"
|
||||
#define SD_PATH "fs:/vol/external01/"
|
||||
#define DEFAULT_AROMA_ENVIRONMENT_PATH "wiiu/environments/aroma"
|
||||
#define DEFAULT_TIRAMISU_ENVIRONMENT_PATH "wiiu/environments/tiramisu"
|
||||
#define DEFAULT_AROMA_ENVIRONMENT_SD_PATH SD_PATH DEFAULT_AROMA_ENVIRONMENT_PATH
|
||||
#define DEFAULT_TIRAMISU_ENVIRONMENT_SD_PATH SD_PATH DEFAULT_TIRAMISU_ENVIRONMENT_PATH
|
||||
#define UPDATE_OLD_SUFFIX ".update.old"
|
||||
#define UPDATE_TEMP_SUFFIX ".update.temp"
|
||||
|
||||
#define UPDATER_VERSION "v0.2.2"
|
||||
#define UPDATER_VERSION_FULL UPDATER_VERSION UPDATER_VERSION_EXTRA
|
||||
#define UPDATER_VERSION "v0.2.2"
|
||||
#define UPDATER_VERSION_FULL UPDATER_VERSION UPDATER_VERSION_EXTRA
|
||||
|
@ -1,15 +1,12 @@
|
||||
#include "DownloadUtils.h"
|
||||
#include "../common.h"
|
||||
#include "FSUtils.h"
|
||||
#include "cacert_pem.h"
|
||||
#include "logger.h"
|
||||
#include <coreinit/cache.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
#define IO_BUFSIZE (128 * 1024) // 128 KB
|
||||
|
||||
bool DownloadUtils::libInitDone = false;
|
||||
uint8_t *DownloadUtils::cacert_pem = nullptr;
|
||||
uint32_t DownloadUtils::cacert_pem_size = 0;
|
||||
bool DownloadUtils::libInitDone = false;
|
||||
|
||||
static int initSocket(void *ptr, curl_socket_t socket, curlsocktype type) {
|
||||
int o = 1;
|
||||
@ -64,14 +61,6 @@ bool DownloadUtils::Init() {
|
||||
return false;
|
||||
}
|
||||
|
||||
cacert_pem = nullptr;
|
||||
cacert_pem_size = 0;
|
||||
if (LoadFileToMem(CERT_FILE_LOCATION, &cacert_pem, &cacert_pem_size) < 0) {
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to load cert");
|
||||
cacert_pem = nullptr;
|
||||
cacert_pem_size = 0;
|
||||
}
|
||||
|
||||
libInitDone = true;
|
||||
return true;
|
||||
}
|
||||
@ -81,11 +70,6 @@ void DownloadUtils::Deinit() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (cacert_pem != nullptr) {
|
||||
free(cacert_pem);
|
||||
cacert_pem = nullptr;
|
||||
cacert_pem_size = 0;
|
||||
}
|
||||
curl_global_cleanup();
|
||||
libInitDone = false;
|
||||
}
|
||||
@ -102,20 +86,13 @@ int DownloadUtils::DownloadFileToBuffer(const std::string &url, std::string &out
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (cacert_pem != nullptr) {
|
||||
struct curl_blob blob {};
|
||||
blob.data = (void *) cacert_pem;
|
||||
blob.len = cacert_pem_size;
|
||||
blob.flags = CURL_BLOB_COPY;
|
||||
struct curl_blob blob {};
|
||||
blob.data = (void *) cacert_pem;
|
||||
blob.len = cacert_pem_size;
|
||||
blob.flags = CURL_BLOB_COPY;
|
||||
|
||||
// Use the certificate bundle in the data
|
||||
curl_easy_setopt(curl, CURLOPT_CAINFO_BLOB, &blob);
|
||||
} else {
|
||||
errorOut = 0x13371337;
|
||||
errorTextOut = "cacert.pem is not loaded";
|
||||
DEBUG_FUNCTION_LINE_ERR("Warning, missing certificate.");
|
||||
return -4;
|
||||
}
|
||||
// Use the certificate bundle in the data
|
||||
curl_easy_setopt(curl, CURLOPT_CAINFO_BLOB, &blob);
|
||||
|
||||
// Enable optimizations
|
||||
curl_easy_setopt(curl, CURLOPT_SOCKOPTFUNCTION, initSocket);
|
||||
|
@ -5,13 +5,11 @@
|
||||
class DownloadUtils {
|
||||
public:
|
||||
static bool Init();
|
||||
|
||||
static void Deinit();
|
||||
|
||||
static int DownloadFileToBuffer(const std::string &url, std::string &outBuffer, int &responseCodeOut, int &errorOut, std::string &errorTextOut, float *progress);
|
||||
|
||||
static uint32_t cacert_pem_size;
|
||||
|
||||
private:
|
||||
static bool libInitDone;
|
||||
static uint8_t *cacert_pem;
|
||||
};
|
Loading…
Reference in New Issue
Block a user