Commit efed9d81 authored by Santtu Lakkala's avatar Santtu Lakkala

[connman] Add inlined variants of certificates and keys. Contributes to: JB#44692

parent 4eb3ac5e
......@@ -47,12 +47,15 @@ struct connman_config_service {
char *identity;
char *anonymous_identity;
char *ca_cert_file;
char *ca_cert;
char *subject_match;
char *altsubject_match;
char *domain_suffix_match;
char *domain_match;
char *client_cert_file;
char *client_cert;
char *private_key_file;
char *private_key;
char *private_key_passphrase;
char *private_key_passphrase_type;
char *phase2;
......@@ -98,8 +101,11 @@ static bool cleanup = false;
#define SERVICE_KEY_SSID "SSID"
#define SERVICE_KEY_EAP "EAP"
#define SERVICE_KEY_CA_CERT "CACertFile"
#define SERVICE_KEY_CA_CERT_DATA "CACert"
#define SERVICE_KEY_CL_CERT "ClientCertFile"
#define SERVICE_KEY_CL_CERT_DATA "ClientCert"
#define SERVICE_KEY_PRV_KEY "PrivateKeyFile"
#define SERVICE_KEY_PRV_KEY_DATA "PrivateKey"
#define SERVICE_KEY_PRV_KEY_PASS "PrivateKeyPassphrase"
#define SERVICE_KEY_PRV_KEY_PASS_TYPE "PrivateKeyPassphraseType"
#define SERVICE_KEY_IDENTITY "Identity"
......@@ -134,8 +140,11 @@ static const char *service_possible_keys[] = {
SERVICE_KEY_SSID,
SERVICE_KEY_EAP,
SERVICE_KEY_CA_CERT,
SERVICE_KEY_CA_CERT_DATA,
SERVICE_KEY_CL_CERT,
SERVICE_KEY_CL_CERT_DATA,
SERVICE_KEY_PRV_KEY,
SERVICE_KEY_PRV_KEY_DATA,
SERVICE_KEY_PRV_KEY_PASS,
SERVICE_KEY_PRV_KEY_PASS_TYPE,
SERVICE_KEY_IDENTITY,
......@@ -237,12 +246,15 @@ free_only:
g_free(config_service->identity);
g_free(config_service->anonymous_identity);
g_free(config_service->ca_cert_file);
g_free(config_service->ca_cert);
g_free(config_service->subject_match);
g_free(config_service->altsubject_match);
g_free(config_service->domain_suffix_match);
g_free(config_service->domain_match);
g_free(config_service->client_cert_file);
g_free(config_service->client_cert);
g_free(config_service->private_key_file);
g_free(config_service->private_key);
g_free(config_service->private_key_passphrase);
g_free(config_service->private_key_passphrase_type);
g_free(config_service->phase2);
......@@ -637,22 +649,58 @@ static bool load_service(GKeyFile *keyfile, const char *group,
service->eap = str;
}
str = __connman_config_get_string(keyfile, group, SERVICE_KEY_CA_CERT, NULL);
str = __connman_config_get_string(keyfile, group, SERVICE_KEY_CA_CERT_DATA, NULL);
if (str) {
g_free(service->ca_cert);
service->ca_cert = str;
g_free(service->ca_cert_file);
service->ca_cert_file = str;
service->ca_cert_file = NULL;
} else {
str = __connman_config_get_string(keyfile, group, SERVICE_KEY_CA_CERT, NULL);
if (str) {
g_free(service->ca_cert_file);
service->ca_cert_file = str;
g_free(service->ca_cert);
service->ca_cert = NULL;
}
}
str = __connman_config_get_string(keyfile, group, SERVICE_KEY_CL_CERT, NULL);
str = __connman_config_get_string(keyfile, group, SERVICE_KEY_CL_CERT_DATA, NULL);
if (str) {
g_free(service->client_cert);
service->client_cert = str;
g_free(service->client_cert_file);
service->client_cert_file = str;
service->client_cert_file = NULL;
} else {
str = __connman_config_get_string(keyfile, group, SERVICE_KEY_CL_CERT, NULL);
if (str) {
g_free(service->client_cert_file);
service->client_cert_file = str;
g_free(service->client_cert);
service->client_cert = NULL;
}
}
str = __connman_config_get_string(keyfile, group, SERVICE_KEY_PRV_KEY, NULL);
str = __connman_config_get_string(keyfile, group, SERVICE_KEY_PRV_KEY_DATA, NULL);
if (str) {
g_free(service->private_key);
service->private_key = str;
g_free(service->private_key_file);
service->private_key_file = str;
service->private_key_file = NULL;
} else {
str = __connman_config_get_string(keyfile, group, SERVICE_KEY_PRV_KEY, NULL);
if (str) {
g_free(service->private_key_file);
service->private_key_file = str;
g_free(service->private_key);
service->private_key = NULL;
}
}
str = __connman_config_get_string(keyfile, group,
......@@ -1099,7 +1147,10 @@ static void provision_service_wifi(struct connman_config_service *config,
__connman_service_set_string(service, "AnonymousIdentity",
config->anonymous_identity);
if (config->ca_cert_file)
if (config->ca_cert)
__connman_service_set_string(service, "CACert",
config->ca_cert);
else if (config->ca_cert_file)
__connman_service_set_string(service, "CACertFile",
config->ca_cert_file);
......@@ -1119,11 +1170,17 @@ static void provision_service_wifi(struct connman_config_service *config,
__connman_service_set_string(service, "DomainMatch",
config->domain_match);
if (config->client_cert_file)
if (config->client_cert)
__connman_service_set_string(service, "ClientCert",
config->client_cert);
else if (config->client_cert_file)
__connman_service_set_string(service, "ClientCertFile",
config->client_cert_file);
if (config->private_key_file)
if (config->private_key)
__connman_service_set_string(service, "PrivateKey",
config->private_key);
else if (config->private_key_file)
__connman_service_set_string(service, "PrivateKeyFile",
config->private_key_file);
......
......@@ -85,12 +85,15 @@ struct connman_network {
char *anonymous_identity;
char *agent_identity;
char *ca_cert_path;
char *ca_cert;
char *subject_match;
char *altsubject_match;
char *domain_suffix_match;
char *domain_match;
char *client_cert_path;
char *client_cert;
char *private_key_path;
char *private_key;
char *private_key_passphrase;
char *phase2_auth;
bool wps;
......@@ -900,12 +903,15 @@ static void network_destruct(struct connman_network *network)
g_free(network->wifi.anonymous_identity);
g_free(network->wifi.agent_identity);
g_free(network->wifi.ca_cert_path);
g_free(network->wifi.ca_cert);
g_free(network->wifi.subject_match);
g_free(network->wifi.altsubject_match);
g_free(network->wifi.domain_suffix_match);
g_free(network->wifi.domain_match);
g_free(network->wifi.client_cert_path);
g_free(network->wifi.client_cert);
g_free(network->wifi.private_key_path);
g_free(network->wifi.private_key);
g_free(network->wifi.private_key_passphrase);
g_free(network->wifi.phase2_auth);
g_free(network->wifi.pin_wps);
......@@ -1909,6 +1915,9 @@ int connman_network_set_string(struct connman_network *network,
} else if (g_str_equal(key, "WiFi.CACertFile")) {
g_free(network->wifi.ca_cert_path);
network->wifi.ca_cert_path = g_strdup(value);
} else if (g_str_equal(key, "WiFi.CACert")) {
g_free(network->wifi.ca_cert);
network->wifi.ca_cert = g_strdup(value);
} else if (g_str_equal(key, "WiFi.SubjectMatch")) {
g_free(network->wifi.subject_match);
network->wifi.subject_match = g_strdup(value);
......@@ -1924,9 +1933,15 @@ int connman_network_set_string(struct connman_network *network,
} else if (g_str_equal(key, "WiFi.ClientCertFile")) {
g_free(network->wifi.client_cert_path);
network->wifi.client_cert_path = g_strdup(value);
} else if (g_str_equal(key, "WiFi.ClientCert")) {
g_free(network->wifi.client_cert);
network->wifi.client_cert = g_strdup(value);
} else if (g_str_equal(key, "WiFi.PrivateKeyFile")) {
g_free(network->wifi.private_key_path);
network->wifi.private_key_path = g_strdup(value);
} else if (g_str_equal(key, "WiFi.PrivateKey")) {
g_free(network->wifi.private_key);
network->wifi.private_key = g_strdup(value);
} else if (g_str_equal(key, "WiFi.PrivateKeyPassphrase")) {
g_free(network->wifi.private_key_passphrase);
network->wifi.private_key_passphrase = g_strdup(value);
......@@ -1977,6 +1992,8 @@ const char *connman_network_get_string(struct connman_network *network,
return network->wifi.agent_identity;
else if (g_str_equal(key, "WiFi.CACertFile"))
return network->wifi.ca_cert_path;
else if (g_str_equal(key, "WiFi.CACert"))
return network->wifi.ca_cert;
else if (g_str_equal(key, "WiFi.SubjectMatch"))
return network->wifi.subject_match;
else if (g_str_equal(key, "WiFi.AltSubjectMatch"))
......@@ -1987,8 +2004,12 @@ const char *connman_network_get_string(struct connman_network *network,
return network->wifi.domain_match;
else if (g_str_equal(key, "WiFi.ClientCertFile"))
return network->wifi.client_cert_path;
else if (g_str_equal(key, "WiFi.ClientCert"))
return network->wifi.client_cert;
else if (g_str_equal(key, "WiFi.PrivateKeyFile"))
return network->wifi.private_key_path;
else if (g_str_equal(key, "WiFi.PrivateKey"))
return network->wifi.private_key;
else if (g_str_equal(key, "WiFi.PrivateKeyPassphrase"))
return network->wifi.private_key_passphrase;
else if (g_str_equal(key, "WiFi.Phase2"))
......
......@@ -243,12 +243,15 @@ struct connman_service {
char *anonymous_identity;
char *agent_identity;
char *ca_cert_file;
char *ca_cert;
char *subject_match;
char *altsubject_match;
char *domain_suffix_match;
char *domain_match;
char *client_cert_file;
char *client_cert;
char *private_key_file;
char *private_key;
char *private_key_passphrase;
char *phase2;
DBusMessage *pending;
......@@ -855,6 +858,8 @@ static void service_apply(struct connman_service *service, GKeyFile *keyfile)
&service->anonymous_identity);
get_config_string(keyfile, service->identifier, "CACertFile",
&service->ca_cert_file);
get_config_string(keyfile, service->identifier, "CACert",
&service->ca_cert);
get_config_string(keyfile, service->identifier, "SubjectMatch",
&service->subject_match);
get_config_string(keyfile, service->identifier, "AltSubjectMatch",
......@@ -865,8 +870,12 @@ static void service_apply(struct connman_service *service, GKeyFile *keyfile)
&service->domain_match);
get_config_string(keyfile, service->identifier, "ClientCertFile",
&service->client_cert_file);
get_config_string(keyfile, service->identifier, "ClientCert",
&service->client_cert);
get_config_string(keyfile, service->identifier, "PrivateKeyFile",
&service->private_key_file);
get_config_string(keyfile, service->identifier, "PrivateKey",
&service->private_key);
get_config_string(keyfile, service->identifier, "PrivateKeyPassphrase",
&service->private_key_passphrase);
get_config_string(keyfile, service->identifier, "Phase2",
......@@ -1040,6 +1049,8 @@ static int service_save(struct connman_service *service)
"AnonymousIdentity", service->anonymous_identity);
set_config_string(keyfile, service->identifier,
"CACertFile", service->ca_cert_file);
set_config_string(keyfile, service->identifier,
"CACert", service->ca_cert);
set_config_string(keyfile, service->identifier,
"SubjectMatch", service->subject_match);
set_config_string(keyfile, service->identifier,
......@@ -1050,8 +1061,12 @@ static int service_save(struct connman_service *service)
"DomainMatch", service->domain_match);
set_config_string(keyfile, service->identifier,
"ClientCertFile", service->client_cert_file);
set_config_string(keyfile, service->identifier,
"ClientCert", service->client_cert);
set_config_string(keyfile, service->identifier,
"PrivateKeyFile", service->private_key_file);
set_config_string(keyfile, service->identifier,
"PrivateKey", service->private_key);
set_config_string(keyfile, service->identifier,
"PrivateKeyPassphrase", service->private_key_passphrase);
set_config_string(keyfile, service->identifier,
......@@ -6041,12 +6056,15 @@ static void service_free(gpointer user_data)
g_free(service->anonymous_identity);
g_free(service->agent_identity);
g_free(service->ca_cert_file);
g_free(service->ca_cert);
g_free(service->subject_match);
g_free(service->altsubject_match);
g_free(service->domain_suffix_match);
g_free(service->domain_match);
g_free(service->client_cert_file);
g_free(service->client_cert);
g_free(service->private_key_file);
g_free(service->private_key);
g_free(service->private_key_passphrase);
g_free(service->phase2);
g_free(service->config_file);
......@@ -6645,6 +6663,9 @@ void __connman_service_set_string(struct connman_service *service,
} else if (g_str_equal(key, "CACertFile")) {
g_free(service->ca_cert_file);
service->ca_cert_file = g_strdup(value);
} else if (g_str_equal(key, "CACert")) {
g_free(service->ca_cert);
service->ca_cert = g_strdup(value);
} else if (g_str_equal(key, "SubjectMatch")) {
g_free(service->subject_match);
service->subject_match = g_strdup(value);
......@@ -6660,9 +6681,15 @@ void __connman_service_set_string(struct connman_service *service,
} else if (g_str_equal(key, "ClientCertFile")) {
g_free(service->client_cert_file);
service->client_cert_file = g_strdup(value);
} else if (g_str_equal(key, "ClientCert")) {
g_free(service->client_cert);
service->client_cert = g_strdup(value);
} else if (g_str_equal(key, "PrivateKeyFile")) {
g_free(service->private_key_file);
service->private_key_file = g_strdup(value);
} else if (g_str_equal(key, "PrivateKey")) {
g_free(service->private_key);
service->private_key = g_strdup(value);
} else if (g_str_equal(key, "PrivateKeyPassphrase")) {
g_free(service->private_key_passphrase);
service->private_key_passphrase = g_strdup(value);
......@@ -7571,7 +7598,10 @@ static void prepare_8021x(struct connman_service *service)
"WiFi.AnonymousIdentity",
service->anonymous_identity);
if (service->ca_cert_file)
if (service->ca_cert)
connman_network_set_string(service->network, "WiFi.CACert",
service->ca_cert);
else if (service->ca_cert_file)
connman_network_set_string(service->network, "WiFi.CACertFile",
service->ca_cert_file);
......@@ -7591,12 +7621,20 @@ static void prepare_8021x(struct connman_service *service)
connman_network_set_string(service->network, "WiFi.DomainMatch",
service->domain_match);
if (service->client_cert_file)
if (service->client_cert)
connman_network_set_string(service->network,
"WiFi.ClientCert",
service->client_cert);
else if (service->client_cert_file)
connman_network_set_string(service->network,
"WiFi.ClientCertFile",
service->client_cert_file);
if (service->private_key_file)
if (service->private_key)
connman_network_set_string(service->network,
"WiFi.PrivateKey",
service->private_key);
else if (service->private_key_file)
connman_network_set_string(service->network,
"WiFi.PrivateKeyFile",
service->private_key_file);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment