From 69d4eabe73cef39fd7fb9a8d99d85221dbcb8fe3 Mon Sep 17 00:00:00 2001 From: Willieodwyer Date: Tue, 8 Mar 2022 18:34:22 +0000 Subject: [PATCH] Fix error absolute paths --- examples/openssl_publisher.c | 16 ++++++++-------- examples/templates/openssl_sockets.h | 10 +++++----- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/examples/openssl_publisher.c b/examples/openssl_publisher.c index 006e00d..b7ff454 100644 --- a/examples/openssl_publisher.c +++ b/examples/openssl_publisher.c @@ -42,8 +42,8 @@ int main(int argc, const char *argv[]) const char* port; const char* topic; const char* ca_file; - const char* cert_path; - const char* key_path; + const char* cert_file; + const char* key_file; /* Load OpenSSL */ SSL_load_error_strings(); @@ -84,20 +84,20 @@ int main(int argc, const char *argv[]) /* get client cert */ if (argc > 5) { - cert_path = argv[5]; + cert_file = argv[5]; } else { - cert_path = NULL; + cert_file = NULL; } /* get client key */ if (argc > 6) { - key_path = argv[6]; + key_file = argv[6]; } else { - key_path = NULL; + key_file = NULL; } /* open the non-blocking TCP socket (connecting to the broker) */ - open_nb_socket(&sockfd, &ssl_ctx, addr, port, ca_file, NULL, cert_path, key_path); + open_nb_socket(&sockfd, &ssl_ctx, addr, port, ca_file, NULL, cert_file, key_file); if (sockfd == NULL) { exit_example(EXIT_FAILURE, sockfd, NULL); @@ -181,4 +181,4 @@ void* client_refresher(void* client) usleep(100000U); } return NULL; -} \ No newline at end of file +} diff --git a/examples/templates/openssl_sockets.h b/examples/templates/openssl_sockets.h index 75a954a..09548b5 100644 --- a/examples/templates/openssl_sockets.h +++ b/examples/templates/openssl_sockets.h @@ -14,8 +14,8 @@ void open_nb_socket(BIO** bio, const char* port, const char* ca_file, const char* ca_path, - const char* cert_path, - const char* key_path) + const char* cert_file, + const char* key_file) { *ssl_ctx = SSL_CTX_new(SSLv23_client_method()); SSL* ssl; @@ -26,15 +26,15 @@ void open_nb_socket(BIO** bio, exit(1); } - if (cert_path && key_path) + if (cert_file && key_file) { - if (!SSL_CTX_use_certificate_file(*ssl_ctx, "/home/will/mqtt-certs/client.crt", SSL_FILETYPE_PEM)) + if (!SSL_CTX_use_certificate_file(*ssl_ctx, cert_file, SSL_FILETYPE_PEM)) { printf("error: failed to load client certificate\n"); exit(1); } - if (!SSL_CTX_use_PrivateKey_file(*ssl_ctx, "/home/will/mqtt-certs/client.key", SSL_FILETYPE_PEM)) + if (!SSL_CTX_use_PrivateKey_file(*ssl_ctx, key_file, SSL_FILETYPE_PEM)) { printf("error: failed to load client key\n"); exit(1);