[PATCH 08/12] hs20-client: specify spp.xsd, pass ca-fname to curl

greearb at candelatech.com greearb
Thu Mar 26 14:39:54 PDT 2015


From: Ben Greear <greearb at candelatech.com>

Allow user to specify the path to the spp.xsd file.

Use configured 'osu-ca.pem' file if user has specified one.
If not, then use the default osu-ca.pem when calling libcurl.

Add some debugging messages as well.

Signed-off-by: Ben Greear <greearb at candelatech.com>
---
 hs20/client/osu_client.c | 40 ++++++++++++++++++++++++++++++----------
 hs20/client/osu_client.h |  3 +++
 hs20/client/spp_client.c |  6 ++++--
 3 files changed, 37 insertions(+), 12 deletions(-)

diff --git a/hs20/client/osu_client.c b/hs20/client/osu_client.c
index 66fef63..d8a8287 100644
--- a/hs20/client/osu_client.c
+++ b/hs20/client/osu_client.c
@@ -1,4 +1,4 @@
-/*
+/* -*-linux-c-*-
  * Hotspot 2.0 OSU client
  * Copyright (c) 2012-2014, Qualcomm Atheros, Inc.
  *
@@ -25,6 +25,8 @@
 #include "crypto/sha256.h"
 #include "osu_client.h"
 
+/* global variables */
+const char *spp_xsd_fname = "spp.xsd";
 
 void write_result(struct hs20_osu_client *ctx, const char *fmt, ...)
 {
@@ -547,8 +549,8 @@ int hs20_add_pps_mo(struct hs20_osu_client *ctx, const char *uri,
 	wpa_printf(MSG_INFO, "SP FQDN: %s", fqdn);
 
 	if (!server_dnsname_suffix_match(ctx, fqdn)) {
-		wpa_printf(MSG_INFO, "FQDN '%s' for new PPS MO did not have suffix match with server's dNSName values",
-			   fqdn);
+		wpa_printf(MSG_INFO, "FQDN '%s' for new PPS MO did not have suffix match with server's dNSName values, count: %d",
+			   fqdn, (int)(ctx->server_dnsname_count));
 		write_result(ctx, "FQDN '%s' for new PPS MO did not have suffix match with server's dNSName values",
 			     fqdn);
 		free(fqdn);
@@ -2036,10 +2038,18 @@ static int osu_connect(struct hs20_osu_client *ctx, const char *bssid,
 	if (set_network_quoted(ifname, id, "ssid", ssid) < 0)
 		return -1;
 	if (osu_nai && os_strlen(osu_nai) > 0) {
-		char dir[255], fname[300];
-		if (getcwd(dir, sizeof(dir)) == NULL)
-			return -1;
-		os_snprintf(fname, sizeof(fname), "%s/osu-ca.pem", dir);
+		char fname[300];
+                if (ctx->ca_fname) {
+			strncpy(fname, ctx->ca_fname, sizeof(fname));
+                }
+                else {
+			char dir[255];
+			if (getcwd(dir, sizeof(dir)) == NULL)
+				return -1;
+			os_snprintf(fname, sizeof(fname), "%s/osu-ca.pem", dir);
+			ctx->ca_fname = strdup(fname); /* so lib curl can use it. */
+                }
+                fname[sizeof(fname) - 1] = 0; /* ensure null termination */
 
 		if (set_network(ifname, id, "proto", "OSEN") < 0 ||
 		    set_network(ifname, id, "key_mgmt", "OSEN") < 0 ||
@@ -2094,8 +2104,10 @@ static int osu_connect(struct hs20_osu_client *ctx, const char *bssid,
 	}
 
 	ctx->no_reconnect = 1;
-	if (methods & 0x02)
+	if (methods & 0x02) {
+		wpa_printf(MSG_DEBUG, "Calling cmd-prov from osu_connect\n");
 		res = cmd_prov(ctx, url);
+	}
 	else if (methods & 0x01)
 		res = cmd_oma_dm_prov(ctx, url);
 
@@ -2290,8 +2302,10 @@ selected:
 		}
 
 		if (connect == 2) {
-			if (last->methods & 0x02)
+			if (last->methods & 0x02) {
+				wpa_printf(MSG_DEBUG, "Calling cmd-prov from cmd_osu_select\n");
 				ret = cmd_prov(ctx, last->url);
+			}
 			else if (last->methods & 0x01)
 				ret = cmd_oma_dm_prov(ctx, last->url);
 			else
@@ -2769,6 +2783,7 @@ static int osu_cert_cb(void *_ctx, struct http_cert *cert)
 		     j < ctx->friendly_name_count; j++) {
 		int found = 0;
 		for (i = 0; i < cert->num_othername; i++) {
+			wpa_printf(MSG_INFO, "othername: %s\n", (char*)(cert->othername[i].data));
 			if (os_strcmp(cert->othername[i].oid,
 				      "1.3.6.1.4.1.40808.1.1.1") != 0)
 				continue;
@@ -2955,6 +2970,7 @@ static void usage(void)
 	       "    [-w<wpa_supplicant ctrl_iface dir>] "
 	       "[-r<result file>] [-f<debug file>] \\\n"
 	       "    [-s<summary file>] \\\n"
+	       "    [-x<spp.xsd file name>] \\\n"
 	       "    <command> [arguments..]\n"
 	       "commands:\n"
 	       "- to_tnds <XML MO> <XML MO in TNDS format> [URN]\n"
@@ -2996,7 +3012,7 @@ int main(int argc, char *argv[])
 		return -1;
 
 	for (;;) {
-		c = getopt(argc, argv, "df:hKNO:qr:s:S:tw:");
+		c = getopt(argc, argv, "df:hKNO:qr:s:S:tw:x:");
 		if (c < 0)
 			break;
 		switch (c) {
@@ -3034,6 +3050,9 @@ int main(int argc, char *argv[])
 		case 'w':
 			wpas_ctrl_path = optarg;
 			break;
+		case 'x':
+			spp_xsd_fname = strdup(optarg);
+			break;
 		case 'h':
 		default:
 			usage();
@@ -3108,6 +3127,7 @@ int main(int argc, char *argv[])
 			exit(0);
 		}
 		ctx.ca_fname = argv[optind + 2];
+		wpa_printf(MSG_DEBUG, "Calling cmd-prov from main\n");
 		cmd_prov(&ctx, argv[optind + 1]);
 	} else if (strcmp(argv[optind], "sim_prov") == 0) {
 		if (argc - optind < 2) {
diff --git a/hs20/client/osu_client.h b/hs20/client/osu_client.h
index 9a7059e..339238e 100644
--- a/hs20/client/osu_client.h
+++ b/hs20/client/osu_client.h
@@ -115,4 +115,7 @@ int est_build_csr(struct hs20_osu_client *ctx, const char *url);
 int est_simple_enroll(struct hs20_osu_client *ctx, const char *url,
 		      const char *user, const char *pw);
 
+/* global variables */
+extern const char *spp_xsd_fname;
+
 #endif /* OSU_CLIENT_H */
diff --git a/hs20/client/spp_client.c b/hs20/client/spp_client.c
index 302a050..ca621e7 100644
--- a/hs20/client/spp_client.c
+++ b/hs20/client/spp_client.c
@@ -59,7 +59,7 @@ static int hs20_spp_validate(struct hs20_osu_client *ctx, xml_node_t *node,
 		return -1;
 	}
 
-	ret = xml_validate(xctx, node, "spp.xsd", &err);
+	ret = xml_validate(xctx, node, spp_xsd_fname, &err);
 	if (ret < 0) {
 		wpa_printf(MSG_INFO, "XML schema validation error(s)\n%s", err);
 		write_summary(ctx, "SPP XML schema validation failed");
@@ -952,7 +952,8 @@ int cmd_prov(struct hs20_osu_client *ctx, const char *url)
 		return -1;
 	}
 
-	wpa_printf(MSG_INFO, "Credential provisioning requested");
+	wpa_printf(MSG_INFO, "Credential provisioning requested, url: %s ca-fname: %s",
+                   url, ctx->ca_fname);
 
 	os_free(ctx->server_url);
 	ctx->server_url = os_strdup(url);
@@ -960,6 +961,7 @@ int cmd_prov(struct hs20_osu_client *ctx, const char *url)
 	if (soap_init_client(ctx->http, url, ctx->ca_fname, NULL, NULL, NULL,
 			     NULL) < 0)
 		return -1;
+
 	spp_post_dev_data(ctx, SPP_SUBSCRIPTION_REGISTRATION,
 			  "Subscription registration", NULL, NULL);
 
-- 
1.9.3




More information about the Hostap mailing list