Fermat's principle in General Relativity