This paper considers a two-way relay network, where two source nodes exchange messages through several relays in the presence of an eavesdropper, and the channel state information (CSI) of the eavesdropper is imperfectly known. The amplify-and-forward relay protocol is used and the relay beamforming weights are designed. The model is built up to minimize the total relay transmit power while guaranteeing the quality of service at users and preventing the eavesdropper from decoding the signals. Due to the imperfect CSI, a semi-infinite programming problem is obtained. An algorithm is proposed to solve the problem, and the iterative points are updated through the linesearch technique, where the feasibility are preserved during iterations. The optimality property is analyzed. The obtained subproblems are quadratic constrained quadratic programming problems, either with less than 4 constraints or with only one variable, which are solved optimally. Simulation results demonstrate the importance of the proposed model, and imply that the proposed algorithm is efficient and converges very fast, where more than 85% of the problems are solved optimally.