Apparently it is from John Milton's Comus: A Mask Presented at Ludlow Castle, which I've only read today.
It was the Victorians who took his phrase and turned it into a proverb, fitting the trend for uplifting and morale boosting proverbs.
Now it feels like a cliche. An overused phrase that even hackneyed journalists or unimaginative politicians would avoid.
But when the sun is behind a dark cloud, it really does look like it has a lining of silver or something. And at the moment that seems to be a very welcome omen.