uclient-fetch: wolfSSL: fix certificate validation
[project/uclient.git] / uclient-fetch.c
index 5f7ac6200bb867690d91468433225820562ad8b3..958f75618194d141d5aaaec74ca0db165a2ae8f2 100644 (file)
@@ -233,6 +233,7 @@ static void header_done_cb(struct uclient *cl)
                        error_ret = 8;
                        break;
                }
+               /* fall through */
        case 204:
        case 200:
                if (no_output)
@@ -502,6 +503,7 @@ static void init_ca_cert(void)
        glob("/etc/ssl/certs/*.crt", 0, NULL, &gl);
        for (i = 0; i < gl.gl_pathc; i++)
                ssl_ops->context_add_ca_crt_file(ssl_ctx, gl.gl_pathv[i]);
+       globfree(&gl);
 }
 
 static void init_ustream_ssl(void)
@@ -589,6 +591,8 @@ int main(int argc, char **argv)
                        switch (longopt_idx) {
                        case L_NO_CHECK_CERTIFICATE:
                                verify = false;
+                               if (ssl_ctx)
+                                       ssl_ops->context_set_require_validation(ssl_ctx, verify);
                                break;
                        case L_CA_CERTIFICATE:
                                has_cert = true;
@@ -607,13 +611,13 @@ int main(int argc, char **argv)
                        case L_USER:
                                if (!strlen(optarg))
                                        break;
-                               username = strdup(optarg);
+                               username = strdupa(optarg);
                                memset(optarg, '*', strlen(optarg));
                                break;
                        case L_PASSWORD:
                                if (!strlen(optarg))
                                        break;
-                               password = strdup(optarg);
+                               password = strdupa(optarg);
                                memset(optarg, '*', strlen(optarg));
                                break;
                        case L_USER_AGENT: