diff options
Diffstat (limited to 'examples/amqps_sendstring.c')
-rw-r--r-- | examples/amqps_sendstring.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/examples/amqps_sendstring.c b/examples/amqps_sendstring.c index fe3ac67..6ef4396 100644 --- a/examples/amqps_sendstring.c +++ b/examples/amqps_sendstring.c @@ -59,7 +59,8 @@ int main(int argc, char const *const *argv) if (argc < 6) { fprintf(stderr, "Usage: amqps_sendstring host port exchange routingkey " - "messagebody [cacert.pem [key.pem cert.pem]]\n"); + "messagebody [cacert.pem [verifypeer] [verifyhostname] " + "[key.pem cert.pem]]\n"); return 1; } @@ -76,17 +77,29 @@ int main(int argc, char const *const *argv) die("creating SSL/TLS socket"); } + amqp_ssl_socket_set_verify_peer(socket, 0); + amqp_ssl_socket_set_verify_hostname(socket, 0); + if (argc > 6) { + int nextarg = 7; status = amqp_ssl_socket_set_cacert(socket, argv[6]); if (status) { die("setting CA certificate"); } - } - - if (argc > 8) { - status = amqp_ssl_socket_set_key(socket, argv[8], argv[7]); - if (status) { - die("setting client cert"); + if (argc > nextarg && !strcmp("verifypeer", argv[nextarg])) { + amqp_ssl_socket_set_verify_peer(socket, 1); + nextarg++; + } + if (argc > nextarg && !strcmp("verifyhostname", argv[nextarg])) { + amqp_ssl_socket_set_verify_hostname(socket, 1); + nextarg++; + } + if (argc > nextarg + 1) { + status = + amqp_ssl_socket_set_key(socket, argv[nextarg + 1], argv[nextarg]); + if (status) { + die("setting client cert"); + } } } |