mirror of
https://github.com/godotengine/godot.git
synced 2026-01-03 18:11:19 +03:00
[NET] Refactor TLS configuration.
Use a TLSOptions configuration object which is created via static functions. - "TLSOptions.client": uses the standard CA and common name verification. - "TLSOptions.client_unsafe": uses optional CA verification (i.e. if specified) - "TLSOptions.server": is the standard server configuration (chain + key) This will allow us to expand the TLS configuration options to include e.g. mutual authentication without bloating the classes that uses StreamPeerTLS and PacketPeerDTLS as underlying peers.
This commit is contained in:
@@ -37,20 +37,20 @@ void HTTPClientWeb::_parse_headers(int p_len, const char **p_headers, void *p_re
|
||||
}
|
||||
}
|
||||
|
||||
Error HTTPClientWeb::connect_to_host(const String &p_host, int p_port, bool p_tls, bool p_verify_host) {
|
||||
Error HTTPClientWeb::connect_to_host(const String &p_host, int p_port, Ref<TLSOptions> p_tls_options) {
|
||||
ERR_FAIL_COND_V(p_tls_options.is_valid() && p_tls_options->is_server(), ERR_INVALID_PARAMETER);
|
||||
|
||||
close();
|
||||
if (p_tls && !p_verify_host) {
|
||||
WARN_PRINT("Disabling HTTPClientWeb's host verification is not supported for the Web platform, host will be verified");
|
||||
}
|
||||
|
||||
port = p_port;
|
||||
use_tls = p_tls;
|
||||
use_tls = p_tls_options.is_valid();
|
||||
|
||||
host = p_host;
|
||||
|
||||
String host_lower = host.to_lower();
|
||||
if (host_lower.begins_with("http://")) {
|
||||
host = host.substr(7, host.length() - 7);
|
||||
use_tls = false;
|
||||
} else if (host_lower.begins_with("https://")) {
|
||||
use_tls = true;
|
||||
host = host.substr(8, host.length() - 8);
|
||||
|
||||
Reference in New Issue
Block a user