Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Signed-off-by: Brice Waegeneire <[email protected]>
  • Loading branch information
bricewge committed Aug 8, 2018
1 parent 8452029 commit fb7d718
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/handle_connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ int handle__connect(struct mosquitto_db *db, struct mosquitto *context)
X509 *client_cert = NULL;
X509_NAME *name;
X509_NAME_ENTRY *name_entry;
ASN1_STRING *name_asn1 = NULL;
#endif

G_CONNECTION_COUNT_INC();
Expand Down Expand Up @@ -447,7 +448,19 @@ int handle__connect(struct mosquitto_db *db, struct mosquitto *context)
}
name_entry = X509_NAME_get_entry(name, i);
if(name_entry){
context->username = mosquitto__strdup((char *)X509_NAME_ENTRY_get_data(name_entry));
name_asn1 = X509_NAME_ENTRY_get_data(name_entry);
if (name_asn1 == NULL) {
send__connack(context, 0, CONNACK_REFUSED_BAD_USERNAME_PASSWORD);
rc = 1;
goto handle_connect_error;
}
context->username = mosquitto__strdup((char *) ASN1_STRING_data(name_asn1));
/* Make sure there isn't an embedded NUL character in the CN */
if ((size_t)ASN1_STRING_length(name_asn1) != strlen(context->username)) {
send__connack(context, 0, CONNACK_REFUSED_BAD_USERNAME_PASSWORD);
rc = 1;
goto handle_connect_error;
}
}
} else { // use_subject_as_username
BIO *subject_bio = BIO_new(BIO_s_mem());
Expand Down

0 comments on commit fb7d718

Please sign in to comment.