fixed certificate handling