diff options
Diffstat (limited to 'examples/amqps_listenq.c')
-rw-r--r-- | examples/amqps_listenq.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/examples/amqps_listenq.c b/examples/amqps_listenq.c index d2e488a..7b26ce1 100644 --- a/examples/amqps_listenq.c +++ b/examples/amqps_listenq.c @@ -53,8 +53,6 @@ int main(int argc, char const *const *argv) { char const *hostname; int port, status; - int hascacert = 0; - int nextarg = 0; char const *queuename; amqp_socket_t *socket; amqp_connection_state_t conn; @@ -80,12 +78,11 @@ int main(int argc, char const *const *argv) amqp_ssl_socket_set_verify_hostname(socket, 0); if (argc > 4) { + int nextarg = 5; status = amqp_ssl_socket_set_cacert(socket, argv[4]); if (status) { die("setting CA certificate"); } - hascacert = 1; - nextarg = 5; if (argc > nextarg && !strcmp("verifypeer", argv[nextarg])) { amqp_ssl_socket_set_verify_peer(socket, 1); nextarg++; @@ -94,15 +91,16 @@ int main(int argc, char const *const *argv) amqp_ssl_socket_set_verify_hostname(socket, 1); nextarg++; } - } - - if (hascacert && argc > nextarg + 1) { - status = amqp_ssl_socket_set_key(socket, argv[nextarg + 1], argv[nextarg]); - if (status) { - die("setting client cert"); + if (argc > nextarg + 1) { + status = + amqp_ssl_socket_set_key(socket, argv[nextarg + 1], argv[nextarg]); + if (status) { + die("setting client cert"); + } } } + status = amqp_socket_open(socket, hostname, port); if (status) { die("opening SSL/TLS connection"); |