diff mbox

[PATCH-v2,2/4] hs20-client: use configured ca-fname instead of cwd.

Message ID 1427847260-1967-2-git-send-email-greearb@candelatech.com
State Changes Requested
Headers show

Commit Message

Ben Greear April 1, 2015, 12:14 a.m. UTC
From: Ben Greear <greearb@candelatech.com>

This gives more flexibility to the hs20 client user.

Signed-off-by: Ben Greear <greearb@candelatech.com>
---
 hs20/client/osu_client.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

Comments

Jouni Malinen April 1, 2015, 5:22 p.m. UTC | #1
On Tue, Mar 31, 2015 at 08:14:18PM -0400, greearb@candelatech.com wrote:
> This gives more flexibility to the hs20 client user.

> diff --git a/hs20/client/osu_client.c b/hs20/client/osu_client.c
> @@ -2036,11 +2036,19 @@ static int osu_connect(struct hs20_osu_client *ctx, const char *bssid,
> +			os_snprintf(fname, sizeof(fname), "%s/osu-ca.pem", dir);
> +			ctx->ca_fname = strdup(fname); /* so lib curl can use it. */

Wouldn't that prevent the existing test case where ctx.ca_fname is left
to NULL on purpose to avoid server certificate validation? In any case,
this strdup part looks independent of rest of the changes and should be
done in a separate commit (or more likely, not done at all, since I
think there is need to allow certificate validation to be disabled for
testing purposes).
diff mbox

Patch

diff --git a/hs20/client/osu_client.c b/hs20/client/osu_client.c
index 649a884..c3d00c0 100644
--- a/hs20/client/osu_client.c
+++ b/hs20/client/osu_client.c
@@ -2036,11 +2036,19 @@  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 ||
 		    set_network(ifname, id, "pairwise", "CCMP") < 0 ||