diff options
author | Martin Willi <martin@revosec.ch> | 2013-04-22 12:42:01 +0200 |
---|---|---|
committer | Martin Willi <martin@revosec.ch> | 2013-05-06 15:54:35 +0200 |
commit | 68fc0fe32eb3d7d89c9639b44903b98a1e073a05 (patch) | |
tree | a31602816effaafe08e52ab9a46f6cbbc58260a2 /src/charon-cmd | |
parent | a0f6f3934323410b18fd0562abda6cb54c4ecf00 (diff) | |
download | strongswan-68fc0fe32eb3d7d89c9639b44903b98a1e073a05.tar.bz2 strongswan-68fc0fe32eb3d7d89c9639b44903b98a1e073a05.tar.xz |
charon-cmd: add an option to set a different server identity
Diffstat (limited to 'src/charon-cmd')
-rw-r--r-- | src/charon-cmd/cmd/cmd_connection.c | 17 | ||||
-rw-r--r-- | src/charon-cmd/cmd/cmd_options.c | 2 | ||||
-rw-r--r-- | src/charon-cmd/cmd/cmd_options.h | 1 |
3 files changed, 19 insertions, 1 deletions
diff --git a/src/charon-cmd/cmd/cmd_connection.c b/src/charon-cmd/cmd/cmd_connection.c index db5499b7c..965b72bc0 100644 --- a/src/charon-cmd/cmd/cmd_connection.c +++ b/src/charon-cmd/cmd/cmd_connection.c @@ -81,6 +81,11 @@ struct private_cmd_connection_t { char *host; /** + * Server identity, or NULL to use host + */ + char *server; + + /** * Local identity */ char *identity; @@ -167,7 +172,14 @@ static void add_auth_cfg(private_cmd_connection_t *this, peer_cfg_t *peer_cfg, } 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); peer_cfg->add_auth_cfg(peer_cfg, auth, local); @@ -367,6 +379,9 @@ METHOD(cmd_connection_t, handle, bool, case CMD_OPT_HOST: this->host = arg; break; + case CMD_OPT_REMOTE_IDENTITY: + this->server = arg; + break; case CMD_OPT_IDENTITY: this->identity = arg; break; diff --git a/src/charon-cmd/cmd/cmd_options.c b/src/charon-cmd/cmd/cmd_options.c index 58877a043..312d12964 100644 --- a/src/charon-cmd/cmd/cmd_options.c +++ b/src/charon-cmd/cmd/cmd_options.c @@ -29,6 +29,8 @@ cmd_option_t cmd_options[CMD_OPT_COUNT] = { "DNS name or address to connect to" }, { CMD_OPT_IDENTITY, "identity", required_argument, "identity", "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", "trusted certificate, for authentication or trust chain validation" }, { CMD_OPT_RSA, "rsa", required_argument, "path", diff --git a/src/charon-cmd/cmd/cmd_options.h b/src/charon-cmd/cmd/cmd_options.h index 165e86212..addbb50d8 100644 --- a/src/charon-cmd/cmd/cmd_options.h +++ b/src/charon-cmd/cmd/cmd_options.h @@ -32,6 +32,7 @@ enum cmd_option_type_t { CMD_OPT_VERSION, CMD_OPT_HOST, CMD_OPT_IDENTITY, + CMD_OPT_REMOTE_IDENTITY, CMD_OPT_CERT, CMD_OPT_RSA, CMD_OPT_LOCAL_TS, |