Unmanned aerial vehicles (UAVs) are widely used in wireless communication networks due to their rapid deployment and high mobility. However, in practical scenarios, the existence of obstacles and eavesdroppers will seriously interfere with the communication quality of the UAV network and produce a security risk. Thus, this paper combines reconfigurable intelligent surface (RIS) technology with UAVs to build a secure UAV communication network. Normally, a rotary-wing UAV (labeled as UAV-S) acting as a base station sends information signals to a legitimate user on the ground with RIS equipment. However, there is a passive eavesdropper on the ground who can steal the information. Therefore, a friendly UAV jammer (labeled as UAV-J) with a fixed location is introduced to send jamming signals to confuse the eavesdropper. The goal of this paper is to maximize the average secrecy rate of the communication network by jointly optimizing the flight trajectory, transmit power of the UAV-S and UAV-J, and phase shifter of the RIS. Since the constructed problem is highly nonconvex, an alternating optimization algorithm based on successive convex approximation techniques is proposed to solve the problem. Simulation results show that the proposed algorithm can achieve a higher secrecy rate in comparison with other schemes.