Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add strdup for the path to tls configuration files. #166

Merged
merged 1 commit into from
Apr 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/nng/mqtt/mqtt_quic.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ struct conf_quic {
uint8_t qcongestion_control; // congestion control algorithm 1: bbr 0: cubic
};

// It is an interface only for ffi.
void conf_quic_tls_create(conf_quic **cqp, char *cafile, char *certfile,
char *keyfile, char *key_pwd);

Expand Down
17 changes: 13 additions & 4 deletions src/mqtt/protocol/mqtt/mqtt_quic.c
Original file line number Diff line number Diff line change
Expand Up @@ -1832,14 +1832,22 @@ nng_mqtt_quic_client_open_conf(nng_socket *sock, const char *url, conf_quic *con
return rv;
}

/*
* It is an interface only for ffi.
*/
void conf_quic_tls_create(conf_quic **cqp, char *cafile, char *certfile,
char *keyfile, char *key_pwd) {
conf_quic *cq = nng_alloc(sizeof(conf_quic));

cq->tls.enable = true;
cq->tls.cafile = cafile;
cq->tls.certfile = certfile;
cq->tls.keyfile = keyfile;
cq->tls.key_password = key_pwd;

// Leak here. But on some ffi.
// The input arguments would be lost when exit current scope.
cq->tls.cafile = strdup(cafile);
cq->tls.certfile = strdup(certfile);
cq->tls.keyfile = strdup(keyfile);
cq->tls.key_password = strdup(key_pwd);

cq->tls.verify_peer = true;
cq->multi_stream = false;
cq->qos_first = false;
Expand All @@ -1850,6 +1858,7 @@ void conf_quic_tls_create(conf_quic **cqp, char *cafile, char *certfile,

*cqp = cq;
}

/**
* init an AIO for Acknoledgement message only, in order to make QoS/connect truly asychrounous
* For QoS 0 message, we do not care the result of sending
Expand Down