Update config to use the new online servers. Remove hardcoded certificate as we will use Let's encrypt from now on (#3690)

This commit is contained in:
Daniel Butum 2019-01-08 02:42:30 +02:00 committed by auriamg
parent f40ac02242
commit b2c11c120b
8 changed files with 79 additions and 79 deletions

View File

@ -1,21 +0,0 @@
-----BEGIN CERTIFICATE-----
MIIDezCCAmOgAwIBAgIJAO+A8uXtEMRsMA0GCSqGSIb3DQEBCwUAMFQxCzAJBgNV
BAYTAlVTMQwwCgYDVQQIDANTVEsxFTATBgNVBAoMDFN1cGVyVHV4S2FydDEgMB4G
A1UEAwwXYWRkb25zLnN1cGVydHV4a2FydC5uZXQwHhcNMTQxMjEwMTEzMTAwWhcN
MjQxMjA3MTEzMTAwWjBUMQswCQYDVQQGEwJVUzEMMAoGA1UECAwDU1RLMRUwEwYD
VQQKDAxTdXBlclR1eEthcnQxIDAeBgNVBAMMF2FkZG9ucy5zdXBlcnR1eGthcnQu
bmV0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2ysZE9rb4y0tHOhk
wxYpqsvDv5LCRFTAeyfAfyBVDcOn+4A3sX8MkQdoH/QDi823z4bn9ZsGV8T444FN
S4yK/aSRv3eAKkkJm5TUxbs3crATVt3JYusMr5W4wHvRVyDe0DlulSdW4EUEklMP
iPat/jwlDZRvZueio3wJoOhZXnl8E8EfnuYtlNONIB1nYGdUHD9xeNyKSPr4zTEp
brjvSw0l5G88LmQOROQBDbTDknAcIQwsFT1mf9Bt+N9LK14r95GWRmL3ZtfbrJn4
ZEfkOjl0Abv6gET4sQOXv0KioUdEJwzFCwKFLZVcuOrscmcHBOhgD3EruVvprIJ0
wZ3z1wIDAQABo1AwTjAdBgNVHQ4EFgQUmQwaPsD+ylVUUsUXMAYpUlnVbNwwHwYD
VR0jBBgwFoAUmQwaPsD+ylVUUsUXMAYpUlnVbNwwDAYDVR0TBAUwAwEB/zANBgkq
hkiG9w0BAQsFAAOCAQEASyl6BMpnZhJlirDL84/RkVeVjBkr7x68UFAblmKjgfGg
pRbYPNSld0IrfZ4pcrDAUkg9WJb0Zxuh0oYiV+RjdW/6s5mF/qiSv8V60xb2myRd
z90ZGfhB5SAECI5zfIZSmsMjOEjKjuz8S26aEtJe8Vq7GF2P7/889lfNXrbvIkZX
HQpx2P+T07zy++6Ca/K2vmWcf1a+GrN+o0nZTYbz/2r/JJwXdWqT1ZmtEA9GNwvZ
J8HhgvspgjgVP/EURUUhOaQ8zfhriU5CJAIuhMhzW7oOBPHxxtxme3auAfxi5zpK
wRNluCayrrjhy2I8mABRnBqgMwAQUIrgk9IU6SyQxw==
-----END CERTIFICATE-----

View File

@ -157,7 +157,7 @@
<minimap size="180.0" ai-icon="16.0" player-icon="20.0"/>
<urls donate="https://supertuxkart.net/Donate"
password-reset="http://addons.supertuxkart.net/password-reset.php" />
password-reset="https://online.supertuxkart.net/password-reset.php" />
<!-- Skidmark data: maximum number of skid marks, and
time for skidmarks to fade out. Maximum number will over

View File

@ -953,8 +953,9 @@ namespace UserConfigParams
PARAM_DEFAULT( IntUserConfigParam(0, "random-identifier", &m_hw_report_group,
"A random number to avoid duplicated reports.") );
// TODO change new-stats to stats before release
PARAM_PREFIX StringUserConfigParam m_server_hw_report
PARAM_DEFAULT( StringUserConfigParam( "http://addons.supertuxkart.net:8080",
PARAM_DEFAULT( StringUserConfigParam( "https://new-stats.supertuxkart.net",
"hw-report-server",
&m_hw_report_group,
"The server used for reporting statistics to."));
@ -978,7 +979,7 @@ namespace UserConfigParams
"Everything related to online play.") );
PARAM_PREFIX StringUserConfigParam m_server_multiplayer
PARAM_DEFAULT( StringUserConfigParam( "https://addons.supertuxkart.net/api/",
PARAM_DEFAULT( StringUserConfigParam( "https://online.supertuxkart.net/api/",
"server_multiplayer",
&m_online_group,
"The server used for online multiplayer."));
@ -996,7 +997,7 @@ namespace UserConfigParams
"Addon and news related settings") );
PARAM_PREFIX StringUserConfigParam m_server_addons
PARAM_DEFAULT( StringUserConfigParam("http://addons.supertuxkart.net/dl/xml",
PARAM_DEFAULT( StringUserConfigParam("https://online.supertuxkart.net/dl/xml",
"server_addons",
&m_addon_group,
"The server used for addon."));

View File

@ -348,8 +348,6 @@ void FileManager::init()
for(int i=0;i<(int)dirs.size(); i++)
pushMusicSearchPath(dirs[i]);
}
m_cert_location = m_file_system->getAbsolutePath(
getAsset("addons.supertuxkart.net.pem").c_str()).c_str();
} // init
//-----------------------------------------------------------------------------
@ -1483,4 +1481,3 @@ bool FileManager::fileIsNewer(const std::string& f1, const std::string& f2) cons
stat(f2.c_str(), &stat2);
return stat1.st_mtime > stat2.st_mtime;
} // fileIsNewer

View File

@ -102,8 +102,6 @@ private:
/** Directory where user-defined grand prix are stored. */
std::string m_gp_dir;
std::string m_cert_location;
std::vector<TextureSearchPath> m_texture_search_path;
std::vector<std::string>
@ -230,7 +228,6 @@ public:
{
return m_subdir_name[SHADER];
}
const std::string& getCertLocation() const { return m_cert_location; }
}; // FileManager
extern FileManager* file_manager;

View File

@ -95,10 +95,10 @@ namespace Online
m_parameters = "";
m_curl_code = CURLE_OK;
m_progress.setAtomic(0);
if (m_http_header == NULL)
if (m_http_header == nullptr)
{
m_http_header = curl_slist_append(m_http_header,
"Host: addons.supertuxkart.net");
std::string Host = "Host: " + StringUtils::getHostNameFromURL(UserConfigParams::m_server_multiplayer);
m_http_header = curl_slist_append(m_http_header, Host.c_str());
}
m_disable_sending_log = false;
} // init
@ -182,19 +182,8 @@ namespace Online
if (m_url.substr(0, 8) == "https://")
{
// https, load certificate info
assert(m_http_header != NULL);
curl_easy_setopt(m_curl_session, CURLOPT_HTTPHEADER,
m_http_header);
const std::string& ci = file_manager->getCertLocation();
CURLcode error = curl_easy_setopt(m_curl_session, CURLOPT_CAINFO,
ci.c_str());
if (error != CURLE_OK)
{
Log::error("HTTPRequest", "Error setting CAINFO to '%s'",
ci.c_str());
Log::error("HTTPRequest", "Error: '%s'.", error,
curl_easy_strerror(error));
}
assert(m_http_header != nullptr);
curl_easy_setopt(m_curl_session, CURLOPT_HTTPHEADER, m_http_header);
curl_easy_setopt(m_curl_session, CURLOPT_SSL_VERIFYPEER, 1L);
#ifdef __APPLE__
curl_easy_setopt(m_curl_session, CURLOPT_SSL_VERIFYHOST, 0L);

View File

@ -908,6 +908,34 @@ namespace StringUtils
return out;
}
// ------------------------------------------------------------------------
std::string getHostNameFromURL(const std::string& url)
{
// Not even a valid URL
if (url.length() < 8)
return "";
// protocol is substr(0, first_color_position)
const size_t first_colon_position = url.find_first_of(":");
if (first_colon_position == std::string::npos)
return "";
// skip ://
const std::string url_without_protocol = url.substr(first_colon_position + 3);
// Find end with port
const size_t port_colon_position = url_without_protocol.find_first_of(":");
if (port_colon_position != std::string::npos)
return url_without_protocol.substr(0, port_colon_position);
// Find end with path
const size_t slash_position = url_without_protocol.find_first_of("/");
if (slash_position != std::string::npos)
return url_without_protocol.substr(0, slash_position);
return url_without_protocol;
}
// ------------------------------------------------------------------------
/** Breaks the text so that each line is smaller than max_width with the current settings.
* The result is put into output, a vector of strings, with each line having its own string */

View File

@ -270,6 +270,15 @@ namespace StringUtils
#endif
return uagent;
}
/**
* Returns the hostname part of an url (if any)
*
* Example https://online.supertuxkart.net/
*
*/
std::string getHostNameFromURL(const std::string& url);
} // namespace StringUtils
#endif