In this paper, we propose a joint source-relay precoding scheme to secure an amplify-and-forward multiple-input multiple-output wireless relay network in the existence of a multi-antenna eavesdropper. Different from existing works that only consider some specific signal design to simplify the problem, we take both the direct links from the source to the destination and to the eavesdropper into account, and investigate the general joint signal covariance matrices optimization problem to maximize the secrecy rate, which leads to a difficult non-convex optimization problem. To handle it, we propose a group alternating optimization algorithm to find a solution, which alternately optimizes the signal covariance matrix and the linear precoding matrix at the source and the relay, respectively. For optimizing the linear precoding matrix at the relay, the problem is still non-convex, and we propose a minorization-maximization (MM) method to handle it. The MM method transforms the original non-convex problem into a series of convex problems and guarantees the convergence of a local optimum. For optimizing the signal covariance matrix at the source, we reveal the convex-concave property of the problem, and find its global optimum using a barrier method combined with the Newton iteration. We also provide an initialization method to trigger the algorithm and analyze the convergence and complexity. The numerical results show the computational efficiency and the prominent performance of the proposed algorithm.