In this article, we consider the system performance of an energy harvesting (EH) wireless sensor network in terms of reliable communications when subjected to a cooperative jamming attack. A set of strategically located nodes acting as cluster heads (CHs) transfer energy to the wireless sensors within range, forming a cluster. The sensors use this energy to transmit data to the CHs, which, in turn, deliver the information to a base station (BS) using nonorthogonal multiple access. The BS processes the collected information and synchronizes the operation of all CHs. Furthermore, there exist two adversaries, namely, a jamming attacker and an eavesdropper, who cooperate to attack the considered system. To protect against this attack, the CHs should be controlled by suitable power allocation coefficients obtained from the security constraints of the CHs. Using these constraints, closed-form expressions are derived to find the power allocation coefficients that will enable reliable and secure communication. In addition, we propose an interference channel selection policy for the sensor-to-CHs links and CHs-to-BS links to improve the reliability of communication while enhancing energy utilization. Finally, an algorithm for finding the optimal EH time is also proposed.