From bbee8579c7b8bac92c24bf743a3ce9ad6ed3ec53 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 16 Nov 2019 14:37:05 +0800 Subject: [PATCH] Login using https --- code/ryzom/client/client_default.cfg | 21 +-- code/ryzom/client/src/client.cpp | 4 + code/ryzom/client/src/client_cfg.cpp | 19 +-- code/ryzom/client/src/http_client_curl.cpp | 2 +- .../src/interface_v3/action_handler_ui.cpp | 2 +- .../src/interface_v3/group_html_webig.cpp | 2 +- code/ryzom/client/src/login.cpp | 127 +++++++++++++++++- code/ryzom/client/src/login.h | 4 +- code/ryzom/client/src/net_manager.cpp | 2 +- 9 files changed, 156 insertions(+), 27 deletions(-) diff --git a/code/ryzom/client/client_default.cfg b/code/ryzom/client/client_default.cfg index 7431807cf..b99c5d154 100644 --- a/code/ryzom/client/client_default.cfg +++ b/code/ryzom/client/client_default.cfg @@ -39,14 +39,15 @@ Gamma_max = 1.0; // NETWORK // ///////////// -Application = { "ryzom_live", "./client_ryzom_r.exe", "./" }; +Application = { "open", "./client_ryzom_r.exe", "./" }; BackgroundDownloader = 0; -StartupHost = "shard.ryzom.com:40916"; +StartupHost = "https://open.ryzom.dev"; StartupPage = "/login/r2_login.php"; +StartupVerify = 1; -ConditionsTermsURL = "http://app.ryzom.com/app_forum/index.php?page=topic/view/21885/1&post148782=en#1"; -LoginSupportURL = "http://app.ryzom.com/app_forum/index.php?page=topic/view/22047/1&post149889=en#1"; -NamingPolicyURL = "http://app.ryzom.com/app_forum/index.php?page=topic/view/21885/1&post148784=en#3"; +ConditionsTermsURL = "http://www.gnu.org/licenses/agpl-3.0.html"; +LoginSupportURL = "https://open.ryzom.dev/ams/"; +NamingPolicyURL = "https://open.ryzom.dev/ams/"; // Full path and filename where cURL can find certificate bundle file // cacert.pem file can be downloaded from https://curl.haxx.se/docs/caextract.html @@ -84,11 +85,15 @@ XMLOutGameInterfaceFiles = { "out_v2_keys.xml", }; +TexturesInterface = "texture_interfaces_v3"; +TexturesInterfaceDXTC = "texture_interfaces_dxtc"; + // The ligo primitive class file LigoPrimitiveClass = "world_editor_classes.xml"; VerboseLog = 1; + /////////// // MOUSE // /////////// @@ -604,11 +609,11 @@ ChannelIgnoreFilter = // interval in minutes for webig notify thread to run WebIgNotifInterval = 10; -WebIgMainDomain = "app.ryzom.com"; +WebIgMainDomain = "https://open.ryzom.dev"; WebIgTrustedDomains = { - "api.ryzom.com", "app.ryzom.com" + "open.ryzom.dev" }; -PatchletUrl = "http://app.ryzom.com/app_patchlet/index.php?patch=preload"; +PatchletUrl = "https://open.ryzom.dev/app_patchlet/index.php?patch=preload"; SelectedSlot = 0; diff --git a/code/ryzom/client/src/client.cpp b/code/ryzom/client/src/client.cpp index 37cb36279..69559e0e8 100644 --- a/code/ryzom/client/src/client.cpp +++ b/code/ryzom/client/src/client.cpp @@ -317,6 +317,10 @@ int main(int argc, char **argv) LoginCustomParameters = "&steam_auth_session_ticket=" + steamClient.getAuthSessionTicket(); #endif +#if !FINAL_VERSION + LoginCustomParameters += "&dbg=1"; +#endif + // initialize patch manager and set the ryzom full path, before it's used CPatchManager *pPM = CPatchManager::getInstance(); pPM->setRyzomFilename(Args.getProgramPath() + Args.getProgramName()); diff --git a/code/ryzom/client/src/client_cfg.cpp b/code/ryzom/client/src/client_cfg.cpp index 7f0222088..bfd6452ee 100644 --- a/code/ryzom/client/src/client_cfg.cpp +++ b/code/ryzom/client/src/client_cfg.cpp @@ -330,9 +330,9 @@ CClientConfig::CClientConfig() TexturesLoginInterface.push_back("texture_interfaces_v3_login"); DisplayAccountButtons = true; - CreateAccountURL = "https://account.ryzom.com/signup/from_client.php"; - EditAccountURL = "https://account.ryzom.com/payment_profile/index.php"; - ForgetPwdURL = "https://account.ryzom.com/payment_profile/lost_secure_password.php"; + CreateAccountURL = "https://open.ryzom.dev/ams/"; + EditAccountURL = "https://open.ryzom.dev/ams/"; + ForgetPwdURL = "https://open.ryzom.dev/ams/"; Position = CVector(0.f, 0.f, 0.f); // Default Position. Heading = CVector(0.f, 1.f, 0.f); // Default Heading. EyesHeight = 1.5f; // Default User Eyes Height. @@ -428,15 +428,15 @@ CClientConfig::CClientConfig() PatchletUrl.clear(); PatchVersion.clear(); - WebIgMainDomain = "atys.ryzom.com"; - WebIgTrustedDomains.push_back(WebIgMainDomain); + WebIgMainDomain = "https://open.ryzom.dev"; + WebIgTrustedDomains.push_back("open.ryzom.dev"); WebIgNotifInterval = 10; // time in minutes CurlMaxConnections = 5; CurlCABundle.clear(); - RingReleaseNotePath = "http://" + WebIgMainDomain + "/releasenotes_ring/index.php"; - ReleaseNotePath = "http://" + WebIgMainDomain + "/releasenotes/index.php"; + RingReleaseNotePath = WebIgMainDomain + "/releasenotes_ring/index.php"; + ReleaseNotePath = WebIgMainDomain + "/releasenotes/index.php"; /////////////// @@ -452,7 +452,7 @@ CClientConfig::CClientConfig() SoundOn = true; // Default is with sound. DriverSound = SoundDrvAuto; SoundForceSoftwareBuffer = true; - SoundOutGameMusic = "Main Menu Loop.ogg"; + SoundOutGameMusic = "main menu loop.ogg"; SoundSFXVolume = 1.f; SoundGameMusicVolume = 1.f; SoundTPFade = 500; @@ -1093,6 +1093,9 @@ void CClientConfig::setValues() /////////// // WEBIG // READ_STRING_FV(WebIgMainDomain); + if (ClientCfg.WebIgMainDomain.find("http://") == std::string::npos + || ClientCfg.WebIgMainDomain.find("https://") == std::string::npos) + ClientCfg.WebIgMainDomain = "http://" + ClientCfg.WebIgMainDomain; READ_STRINGVECTOR_FV(WebIgTrustedDomains); READ_INT_FV(WebIgNotifInterval); READ_INT_FV(CurlMaxConnections); diff --git a/code/ryzom/client/src/http_client_curl.cpp b/code/ryzom/client/src/http_client_curl.cpp index 16436516b..c27672489 100644 --- a/code/ryzom/client/src/http_client_curl.cpp +++ b/code/ryzom/client/src/http_client_curl.cpp @@ -63,7 +63,7 @@ bool CCurlHttpClient::authenticate(const std::string &user, const std::string &p return true; } -static const std::string CAFilename = "ssl_ca_cert.pem"; // this is the certificate "Thawte Server CA" +static const std::string CAFilename = "cacert.pem"; // https://curl.haxx.se/docs/caextract.html // *************************************************************************** bool CCurlHttpClient::verifyServer(bool verify) diff --git a/code/ryzom/client/src/interface_v3/action_handler_ui.cpp b/code/ryzom/client/src/interface_v3/action_handler_ui.cpp index 68b55076e..bf83ddce1 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_ui.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_ui.cpp @@ -416,7 +416,7 @@ class CAHUIShowHide : public IActionHandler nlwarning("%s is not a group html", window.c_str()); return; } - pGH->setURL("http://"+ClientCfg.WebIgMainDomain+"/index.php?app="+webapp); + pGH->setURL(ClientCfg.WebIgMainDomain + "/index.php?app=" + webapp); } } else diff --git a/code/ryzom/client/src/interface_v3/group_html_webig.cpp b/code/ryzom/client/src/interface_v3/group_html_webig.cpp index 8f5c6da01..11fe6c6c5 100644 --- a/code/ryzom/client/src/interface_v3/group_html_webig.cpp +++ b/code/ryzom/client/src/interface_v3/group_html_webig.cpp @@ -267,7 +267,7 @@ public: uint c = 0; while (_Running) { - string url = "https://"+domain+"/index.php?app=notif&format=lua&rnd="+randomString(); + string url = domain + "/index.php?app=notif&format=lua&rnd=" + randomString(); addWebIGParams(url, true); get(url); diff --git a/code/ryzom/client/src/login.cpp b/code/ryzom/client/src/login.cpp index 1eb6ec867..79381d8f2 100644 --- a/code/ryzom/client/src/login.cpp +++ b/code/ryzom/client/src/login.cpp @@ -155,7 +155,8 @@ CLoginStateMachine LoginSM; bool CStartupHttpClient::connectToLogin() { - return connect(ClientCfg.ConfigFile.getVar("StartupHost").asString(0)); + return connect(ClientCfg.ConfigFile.getVar("StartupHost").asString(0)) + && verifyServer(ClientCfg.ConfigFile.getVar("StartupVerify").asBool(0)); } CStartupHttpClient HttpClient; @@ -2825,7 +2826,36 @@ string checkLogin(const string &login, const string &password, const string &cli if(res.empty()) return "Empty answer from server (error code 62)"; - if(res[0] == '0') + size_t first = res.find("\n\n"); + if (first == std::string::npos) + { + first = res.find("\r\r"); + if (first == std::string::npos) + { + first = res.find("\r\n\r\n"); + if (first != std::string::npos) + { + res = res.substr(first + 4); + } + } + else + { + res = res.substr(first + 2); + } + } + else + { + res = res.substr(first + 2); + } + + nldebug("res1: %s", res.c_str()); + + if (res[0] == 'H') + { + nlwarning("missing response body: %s", res.c_str()); + return "missing response body (error code 64)"; + } + else if(res[0] == '0') { // server returns an error nlwarning("server error: %s", res.substr(2).c_str()); @@ -2878,7 +2908,36 @@ string checkLogin(const string &login, const string &password, const string &cli if(res.empty()) return "Empty answer from server (error code 4)"; - if(res[0] == '0') + size_t first = res.find("\n\n"); + if (first == std::string::npos) + { + first = res.find("\r\r"); + if (first == std::string::npos) + { + first = res.find("\r\n\r\n"); + if (first != std::string::npos) + { + res = res.substr(first + 4); + } + } + else + { + res = res.substr(first + 2); + } + } + else + { + res = res.substr(first + 2); + } + + nldebug("res2: %s", res.c_str()); + + if (res[0] == 'H') + { + nlwarning("missing response body: %s", res.c_str()); + return "missing response body (error code 65)"; + } + else if(res[0] == '0') { // server returns an error nlwarning("server error: %s", res.substr(2).c_str()); @@ -2960,7 +3019,36 @@ string checkLogin(const string &login, const string &password, const string &cli if(res.empty()) return "Empty answer from server (error code 4)"; - if(res[0] == '0') + size_t first = res.find("\n\n"); + if (first == std::string::npos) + { + first = res.find("\r\r"); + if (first == std::string::npos) + { + first = res.find("\r\n\r\n"); + if (first != std::string::npos) + { + res = res.substr(first + 4); + } + } + else + { + res = res.substr(first + 2); + } + } + else + { + res = res.substr(first + 2); + } + + nldebug("res2: %s", res.c_str()); + + if (res[0] == 'H') + { + nlwarning("missing response body: %s", res.c_str()); + return "missing response body (error code 66)"; + } + else if(res[0] == '0') { // server returns an error nlwarning("server error: %s", res.substr(2).c_str()); @@ -3065,7 +3153,36 @@ string selectShard(uint32 shardId, string &cookie, string &addr) if(res.empty()) return "Empty result (error code 13)"; - if(res[0] == '0') + size_t first = res.find("\n\n"); + if (first == std::string::npos) + { + first = res.find("\r\r"); + if (first == std::string::npos) + { + first = res.find("\r\n\r\n"); + if (first != std::string::npos) + { + res = res.substr(first + 4); + } + } + else + { + res = res.substr(first + 2); + } + } + else + { + res = res.substr(first + 2); + } + + nldebug("res2: %s", res.c_str()); + + if (res[0] == 'H') + { + nlwarning("missing response body: %s", res.c_str()); + return "missing response body (error code 66)"; + } + else if(res[0] == '0') { // server returns an error nlwarning("server error: %s", res.substr(2).c_str()); diff --git a/code/ryzom/client/src/login.h b/code/ryzom/client/src/login.h index 2c6e8c960..fa4f041c1 100644 --- a/code/ryzom/client/src/login.h +++ b/code/ryzom/client/src/login.h @@ -19,7 +19,7 @@ #define CL_LOGIN_H #include "nel/misc/types_nl.h" -#include "game_share/http_client.h" +#include "http_client_curl.h" #include #include @@ -74,7 +74,7 @@ extern sint32 ShardSelected; /* * HTTP client preconfigured to connect to the startup login host */ -class CStartupHttpClient : public CHttpClient +class CStartupHttpClient : public CCurlHttpClient { public: diff --git a/code/ryzom/client/src/net_manager.cpp b/code/ryzom/client/src/net_manager.cpp index 7bdcfb5ed..d562e5ea4 100644 --- a/code/ryzom/client/src/net_manager.cpp +++ b/code/ryzom/client/src/net_manager.cpp @@ -3292,7 +3292,7 @@ private: if(i != digitMaxEnd) { ucstring web_app = contentStr.substr(digitStart, i-digitStart); - contentStr = ucstring("http://"+ClientCfg.WebIgMainDomain+"/")+web_app+ucstring("/index.php?")+contentStr.substr(i+1); + contentStr = ucstring(ClientCfg.WebIgMainDomain + "/") + web_app + ucstring("/index.php?") + contentStr.substr((size_t)i + 1); } else {