Future fifth-generation (5G) cellular systems are set to give a strong boost to the large-scale deployment of Internet of things (IoT). In the view of a future converged 5G-IoT infrastructure, cellular IoT solutions such as narrowband IoT (NB-IoT) and device-to-device (D2D) communications are key technologies for supporting IoT scenarios and applications. However, some open issues still need careful investigation. An example is the risk of threats to privacy and security when IoT mobile services rely on D2D communications. To guarantee efficient and secure connections to IoT services involving exchange of sensitive data, reputation-based mechanisms to identify and avoid malicious devices are fast gaining ground. In order to tackle the presence of malicious nodes in the network, this paper introduces reliability and reputation notions to model the level of trust among devices engaged in an opportunistic hop-by-hop D2D-based content uploading scheme. To this end, social awareness of devices is considered as a means to enhance the identification of trustworthy nodes. A performance evaluation study shows that the negative effects due to malicious nodes can be drastically reduced by adopting the proposed solution. The performance metrics that proved to benefit from the proposed solution are data loss, energy consumption, and content uploading time. © 2017 by the authors.