The security of wireless sensor networks has attracted much attention in recent years and the key management is the focus. EBS-based dynamic key management scheme is a new approach for wireless sensornetworks. Its major advantages are its enhanced network survivability, high dynamic performance and better support for network expansion. But it suffers from the collusion problem, which means it is prone to the cooperative attack of the compromised nodes. In this paper, the feature of the collusion problem is analyzed and an optimization model is proposed, maximizing the length of the shortest collusion chain, which is the key issue of the problem. A discrete particle swarm optimization algorithm for the collusion problem is also presented based on the optimization model proposed. Simulation results show that compared with the former works, the resilience of the network and the difficulty to compromise the whole network are both greatly improved.