summaryrefslogtreecommitdiff
path: root/examples/amqps_consumer.c
diff options
context:
space:
mode:
Diffstat (limited to 'examples/amqps_consumer.c')
-rw-r--r--examples/amqps_consumer.c38
1 files changed, 28 insertions, 10 deletions
diff --git a/examples/amqps_consumer.c b/examples/amqps_consumer.c
index 31d251d..cb47dff 100644
--- a/examples/amqps_consumer.c
+++ b/examples/amqps_consumer.c
@@ -35,7 +35,7 @@
#include <string.h>
#include <stdint.h>
-#include <amqp-ssl.h>
+#include <amqp-ssl-socket.h>
#include <amqp_framing.h>
#include <assert.h>
@@ -115,13 +115,11 @@ static void run(amqp_connection_state_t conn)
int main(int argc, char const * const *argv) {
char const *hostname;
- int port;
+ int port, status;
char const *exchange;
char const *bindingkey;
-
- int sockfd;
+ amqp_socket_t *socket;
amqp_connection_state_t conn;
-
amqp_bytes_t queuename;
if (argc < 3) {
@@ -137,11 +135,31 @@ int main(int argc, char const * const *argv) {
conn = amqp_new_connection();
- die_on_error(sockfd = amqp_open_ssl_socket(conn, hostname, port,
- argc > 3 ? argv[3] : NULL,
- argc > 5 ? argv[4] : NULL,
- argc > 5 ? argv[5] : NULL),
- "Opening SSL/TLS socket");
+ socket = amqp_ssl_socket_new();
+ if (!socket) {
+ die("creating SSL/TLS socket");
+ }
+
+ if (argc > 3) {
+ status = amqp_ssl_socket_set_cacert(socket, argv[3]);
+ if (status) {
+ die("setting CA certificate");
+ }
+ }
+
+ if (argc > 4) {
+ status = amqp_ssl_socket_set_key(socket, argv[5], argv[5]);
+ if (status) {
+ die("setting client key/cert");
+ }
+ }
+
+ status = amqp_socket_open(socket, hostname, port);
+ if (status) {
+ die("opening SSL/TLS connection");
+ }
+
+ amqp_set_socket(conn, socket);
die_on_amqp_error(amqp_login(conn, "/", 0, 131072, 0, AMQP_SASL_METHOD_PLAIN, "guest", "guest"),
"Logging in");
amqp_channel_open(conn, 1);