General question: Given a vector bundle $E \rightarrow M$ on a complex manifold $M$, and a connection $\nabla$ on $E$, is it possible to find an Hermitian structure on $E$ such that $\nabla$ is the associated metric connection (i.e. the unique connection compatible with both the metric and the complex structure)?
Specific question: Given a line bundle $L \rightarrow X$ on a compact Riemann surface $X$ equipped with a flat connection $\nabla$, is it possible to find an Hermitian structure on $L$ such that $\nabla$ is the associated metric connection?
Motivation: I´m trying to prove that a degree zero line bundle on a compact Riemann surface always admits an harmonic Hermitian metric. By a classical result of Weil and Atiyah every degree zero vector bundle admits a flat connection, moreover I think (though I still did not prove it) that the flatness condition on the connection could be translated (by computation on the vector fields $\partial z$ and $\partial \overline{z}$) into the harmonicity condition on the "associated" (in the sense of the question) Hermitian metric.
The question is clearly related to the well discussed question: When can a Connection Induce a Riemannian Metric for which it is the Levi-Civita Connection. But I´m not able to adjust the proof given in the mentioned question to an answer for my own. I´m asking also a general version of the question because I´m just curious about the answer.
Thank you for your time!
Edit: As pointed out by David Speyer the metric connection is constructed taking as input an Hermitian structure on the bundle and not an Hermitian metric on the manifold. I changed both the questions consequently.