charon-cmd: add an option to set a different server identity
This commit is contained in:
@@ -80,6 +80,11 @@ struct private_cmd_connection_t {
|
|||||||
*/
|
*/
|
||||||
char *host;
|
char *host;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Server identity, or NULL to use host
|
||||||
|
*/
|
||||||
|
char *server;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Local identity
|
* Local identity
|
||||||
*/
|
*/
|
||||||
@@ -167,7 +172,14 @@ static void add_auth_cfg(private_cmd_connection_t *this, peer_cfg_t *peer_cfg,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
id = identification_create_from_string(this->host);
|
if (this->server)
|
||||||
|
{
|
||||||
|
id = identification_create_from_string(this->server);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
id = identification_create_from_string(this->host);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
auth->add(auth, AUTH_RULE_IDENTITY, id);
|
auth->add(auth, AUTH_RULE_IDENTITY, id);
|
||||||
peer_cfg->add_auth_cfg(peer_cfg, auth, local);
|
peer_cfg->add_auth_cfg(peer_cfg, auth, local);
|
||||||
@@ -367,6 +379,9 @@ METHOD(cmd_connection_t, handle, bool,
|
|||||||
case CMD_OPT_HOST:
|
case CMD_OPT_HOST:
|
||||||
this->host = arg;
|
this->host = arg;
|
||||||
break;
|
break;
|
||||||
|
case CMD_OPT_REMOTE_IDENTITY:
|
||||||
|
this->server = arg;
|
||||||
|
break;
|
||||||
case CMD_OPT_IDENTITY:
|
case CMD_OPT_IDENTITY:
|
||||||
this->identity = arg;
|
this->identity = arg;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ cmd_option_t cmd_options[CMD_OPT_COUNT] = {
|
|||||||
"DNS name or address to connect to" },
|
"DNS name or address to connect to" },
|
||||||
{ CMD_OPT_IDENTITY, "identity", required_argument, "identity",
|
{ CMD_OPT_IDENTITY, "identity", required_argument, "identity",
|
||||||
"identity the client uses for the IKE exchange" },
|
"identity the client uses for the IKE exchange" },
|
||||||
|
{ CMD_OPT_REMOTE_IDENTITY, "remote-identity", required_argument, "identity",
|
||||||
|
"server identity to expect, defaults to host" },
|
||||||
{ CMD_OPT_CERT, "cert", required_argument, "path",
|
{ CMD_OPT_CERT, "cert", required_argument, "path",
|
||||||
"trusted certificate, for authentication or trust chain validation" },
|
"trusted certificate, for authentication or trust chain validation" },
|
||||||
{ CMD_OPT_RSA, "rsa", required_argument, "path",
|
{ CMD_OPT_RSA, "rsa", required_argument, "path",
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ enum cmd_option_type_t {
|
|||||||
CMD_OPT_VERSION,
|
CMD_OPT_VERSION,
|
||||||
CMD_OPT_HOST,
|
CMD_OPT_HOST,
|
||||||
CMD_OPT_IDENTITY,
|
CMD_OPT_IDENTITY,
|
||||||
|
CMD_OPT_REMOTE_IDENTITY,
|
||||||
CMD_OPT_CERT,
|
CMD_OPT_CERT,
|
||||||
CMD_OPT_RSA,
|
CMD_OPT_RSA,
|
||||||
CMD_OPT_LOCAL_TS,
|
CMD_OPT_LOCAL_TS,
|
||||||
|
|||||||
Reference in New Issue
Block a user