Improve certificate handling to check valid dates and cert path