The U.S. president expressed hope that the spy chief’s unannounced visit to Russia could help end the war in Ukraine.