Skip to content

Commit

Permalink
Fix error absolute paths
Browse files Browse the repository at this point in the history
  • Loading branch information
Willieodwyer committed Mar 8, 2022
1 parent 659d0e1 commit 69d4eab
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
16 changes: 8 additions & 8 deletions examples/openssl_publisher.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -181,4 +181,4 @@ void* client_refresher(void* client)
usleep(100000U);
}
return NULL;
}
}
10 changes: 5 additions & 5 deletions examples/templates/openssl_sockets.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit 69d4eab

Please sign in to comment.