Suppose one has an $S^1$ principal bundle $p: P\rightarrow M$, and a closed 2-form $F$ on $M$. Then the pullback form $p^*F$ is closed, vanishes on vertical vectors, and is invariant under the action of $S^1$ on $P$. These are all essential characteristics of a curvature form of a connection on an $S^1$ bundle, so my question is:
Is there a connection 1-form $\alpha$ such that d$\alpha=p^*F$? As of now, I'm not even sure how to see that $p^*F$ is trivial in the cohomology of $P$.