Thorough control of the optical mode of a single photon is essential for quantum information applications. We present a comprehensive experimental and theoretical study of a light-matter interface based on cavity quantum electrodynamics. We identify key parameters like the phases of the involved light fields and demonstrate absolute, flexible, and accurate control of the timedependent complex-valued wave function of a single photon over several orders of magnitude. This capability will be an important tool for the development of distributed quantum systems with multiple components that interact via photons.PACS numbers: 42.50.Dv, 42.50.Pq, 32.80.Qk Single photons are of paramount importance for modern quantum information science. Envisioned applications range from all-optical quantum computation [1, 2] to quantum communication in nonlocal quantum clouds [3, 4]. As all the conceived quantum information protocols involve, in one way or another, interference effects, coherent photons are mandatory for the implementation of these protocols [5,6]. This requirement includes the (relative) coherence within the photon wave packet as well as the (absolute) coherence with respect to a common network reference clock. Full control over amplitude and phase of the photon's temporal mode is a challenge [7][8][9][10][11][12][13][14][15][16][17][18][19][20][21][22][23], as is the mode conversion for all regimes from narrow to broad-bandwidth single photons. Meeting these challenges would open up new possibilities like temporal mode matching in multimode quantum networks or information encoding in the optical mode of the photon.Here we exploit the arsenal of cavity quantum electrodynamics (CQED) [24] and demonstrate deterministic mode control over single optical photons. Toward this end, we extend previous models [25][26][27][28][29][30][31][32] and take into account the full energy-level structure of the atom that serves as photon emitter and photon receiver in a highfinesse optical resonator. We find a surprisingly strong frequency dependence of the process efficiency with a pronounced minimum that originates from destructive interference of transition amplitudes. We also show that the emission efficiency is not a reliable measure for photon coherence. We moreover shape the photon phase, demonstrate the mode selectivity of photon absorption, and stretch and compress a given single-photon wave packet by 3 orders of magnitude. All these achievements are realized in combination with a convenientto-implement coherence-testing method that outputs the time-dependent complex-valued temporal mode function with minimal resources [33]. As both the amplitude and the phase of the temporal mode are determined with respect to a commonly accepted reference, a phase-locked laser, we are now in a position to certify the (absolute) coherence of a network photon.Our system uses the quantum memory scheme described in Ref. [34] and therefore all the following results are also valid for single photons encoding a qubit in their polarization degr...