Internet of Things (IoT) has proved its applicability in numerous domains such as healthcare, agriculture, automobile, industrial production, logistics and supply chain management. Looking at the current trend, we expect massive proliferation of such IoT devices all around us. However, one of the issues with the widespread use of IoT is the increasing complexity of the underlying architecture, which lead to difficulty in ensuring security compliance. One of the critical security processes is key refreshment, which needs to be regularly executed in order to guarantee strong security management. However, in most of the cases, keys are not updated and if they are updated, the update-logs are not available for all the entities to verify and build trust. Furthermore, the rules for key refreshment are also not defined in a transparent way. In this paper, we propose secure, decentralized, and automatic key refreshment mechanism for an IoT system. The proposed mechanism enables users to verify the freshness of the security keys (being used) thereby relying on the data from IoT devices and establishing trust in an IoT system. The proposed mechanism is driven by blockchain technology and smart contract. To demonstrate the viability of the proposed solution we have implemented it using both Ethereum and Hyperledger Fabric blockchains.