In the finite blocklength scenario, which is suitable for practical applications, a method of maximizing the average effective secrecy rate (AESR) is proposed for a UAV-enabled secure communication by optimizing the UAVs trajectory and transmit power subject to the UAVs mobility constraints and transmit power constraints. To address the formulated non-convex optimization problem, it is first decomposed into two non-convex subproblems. Then the two subproblems are converted respectively into two convex subproblems via the first-order approximation. Finally, an alternating iteration algorithm is developed by solving the two subproblems iteratively using successive convex approximation (SCA) technique. Numerical results show that our proposed scheme achieves a better AESR performance than both the benchmark schemes.