I have two rectangles as in the picture below which can be located anywhere relative to each other.
I have the coordinates of the rectangle centers (c1 and c2) and the lenght/height of both rectangles.
How can I find the coordinates of points p1 and p2 - where the line between the centers crosses the edges?

If you know the two center points' coordinates, you can come up with an equation for the line between them. Then, say for P2, you can plug in $C2-\frac{L2}{2}$ into your equation for the line for the $x$ value and solve for $y$.
Then solve for P1 similarly.