diff --git a/res/res_pjsip/pjsip_configuration.c b/res/res_pjsip/pjsip_configuration.c
index 1518bcee94c081a38848754d878eebce55cc56e8..60b82eedc578bd4d09cbdb1f663072160f003f1d 100644
--- a/res/res_pjsip/pjsip_configuration.c
+++ b/res/res_pjsip/pjsip_configuration.c
@@ -646,15 +646,15 @@ static int dtls_handler(const struct aco_option *opt,
 {
 	struct ast_sip_endpoint *endpoint = obj;
 	char *name = ast_strdupa(var->name);
-	char *front, *buf = name;
+	char *front, *back, *buf = name;
 
 	/* strip out underscores in the name */
-	front = strtok(buf, "_");
+	front = strtok_r(buf, "_", &back);
 	while (front) {
 		int size = strlen(front);
 		ast_copy_string(buf, front, size + 1);
 		buf += size;
-		front = strtok(NULL, "_");
+		front = strtok_r(NULL, "_", &back);
 	}
 
 	return ast_rtp_dtls_cfg_parse(&endpoint->media.rtp.dtls_cfg, name, var->value);