static char server_port[32] = { '\0' };
static char *opt_proxy = NULL;
static char *opt_no_proxy = NULL;
-static char *opt_path = "/";
+static char *opt_path = NULL;
static int opt_msg_timeout = -1;
static int opt_total_timeout = -1;
OPT_SECTION("Message transfer"),
{"server", OPT_SERVER, 's',
- "[http[s]://]address[:port] of CMP server. Default port 80 or 443."},
+ "[http[s]://]address[:port][/path] of CMP server. Default port 80 or 443."},
{OPT_MORE_STR, 0, 0,
- "The address may be a DNS name or an IP address"},
+ "address may be a DNS name or an IP address; path can be overridden by -path"},
{"proxy", OPT_PROXY, 's',
"[http[s]://]address[:port][/path] of HTTP(S) proxy to use; path is ignored"},
{"no_proxy", OPT_NO_PROXY, 's',
{OPT_MORE_STR, 0, 0,
"Default from environment variable 'no_proxy', else 'NO_PROXY', else none"},
{"path", OPT_PATH, 's',
- "HTTP path (aka CMP alias) at the CMP server. Default \"/\""},
+ "HTTP path (aka CMP alias) at the CMP server. Default from -server, else \"/\""},
{"msg_timeout", OPT_MSG_TIMEOUT, 'n',
"Timeout per CMP message round trip (or 0 for none). Default 120 seconds"},
{"total_timeout", OPT_TOTAL_TIMEOUT, 'n',
static int setup_client_ctx(OSSL_CMP_CTX *ctx, ENGINE *engine)
{
int ret = 0;
- char *server = NULL, *port = NULL, *path = NULL;
+ char *server = NULL, *port = NULL, *path = NULL, *used_path;
int portnum, ssl;
char server_buf[200] = { '\0' };
char proxy_buf[200] = { '\0' };
char *proxy_port_str = NULL;
if (opt_server == NULL) {
- CMP_err("missing server address[:port]");
+ CMP_err("missing -server option");
goto err;
}
if (!OSSL_HTTP_parse_url(opt_server, &server, &port, &portnum, &path, &ssl))
goto err;
}
strncpy(server_port, port, sizeof(server_port));
+ used_path = opt_path != NULL ? opt_path : path;
if (!OSSL_CMP_CTX_set1_server(ctx, server)
|| !OSSL_CMP_CTX_set_serverPort(ctx, portnum)
- || !OSSL_CMP_CTX_set1_serverPath(ctx, opt_path))
+ || !OSSL_CMP_CTX_set1_serverPath(ctx, used_path))
goto oom;
if (opt_proxy != NULL && !OSSL_CMP_CTX_set1_proxy(ctx, opt_proxy))
goto oom;
goto oom;
(void)BIO_snprintf(server_buf, sizeof(server_buf), "http%s://%s:%s/%s",
opt_tls_used ? "s" : "", server, port,
- opt_path[0] == '/' ? opt_path + 1 : opt_path);
+ *used_path == '/' ? used_path + 1 : used_path);
if (opt_proxy != NULL)
(void)BIO_snprintf(proxy_buf, sizeof(proxy_buf), " via %s", opt_proxy);
}
opt_server = mock_server;
opt_proxy = "API";
- } else {
- if (opt_server == NULL) {
- CMP_err("missing -server option");
- goto err;
- }
}
if (!setup_client_ctx(cmp_ctx, engine)) {
[B<-config> I<filename>]
[B<-section> I<names>]
-[B<-server> I<address[:port]>]
+[B<-server> I<[http[s]://]address[:port][/path]>]
[B<-proxy> I<[http[s]://]address[:port][/path]>]
[B<-no_proxy> I<addresses>]
[B<-path> I<remote_path>]
=over 4
-=item B<-server> I<[http[s]://]address[:port]>
+=item B<-server> I<[http[s]://]address[:port][/path]>
The IP address or DNS hostname and optionally port (defaulting to 80 or 443)
of the CMP server to connect to using HTTP(S) transport.
The optional I<http://> or I<https://> prefix is ignored.
+If a path is included it provides the default value for the B<-path> option.
=item B<-proxy> I<[http[s]://]address[:port][/path]>
=item B<-path> I<remote_path>
HTTP path at the CMP server (aka CMP alias) to use for POST requests.
-Defaults to I</>.
+Defaults to any path given with B<-server>, else C<"/">.
=item B<-msg_timeout> I<seconds>
1,proxy default port, -section,, -server,_SERVER_HOST:_SERVER_PORT, -proxy,127.0.0.1,,,BLANK,,BLANK,,BLANK,,BLANK, -no_proxy,nonmatch.com,-msg_timeout,1
1,proxy missing argument, -section,, -server,_SERVER_HOST:_SERVER_PORT, -proxy,,,,BLANK,,BLANK,,BLANK,,BLANK, -no_proxy,nonmatch.com
,,,,,,,,,,,,,,,,,,,,,,,,,
+0,path explicit, -section,, -server,_SERVER_HOST:_SERVER_PORT,,, -path,_SERVER_PATH,BLANK,,BLANK,,BLANK,,BLANK,
+0,path overrides -server path, -section,, -server,_SERVER_HOST:_SERVER_PORT/ignored,,, -path,_SERVER_PATH,BLANK,,BLANK,,BLANK,,BLANK,
+0,path default -server path, -section,, -server,_SERVER_HOST:_SERVER_PORT/_SERVER_PATH,,, -path,"""",BLANK,,BLANK,,BLANK,,BLANK,
1,path missing argument, -section,,,,,, -path,,BLANK,,BLANK,,BLANK,,BLANK,
1,path wrong, -section,,,,,, -path,/publicweb/cmp/example,BLANK,,BLANK,,BLANK,,BLANK,
0,path with additional '/'s fine according to RFC 3986, -section,,,,,, -path,/_SERVER_PATH////,BLANK,,BLANK,,BLANK,,BLANK