Fix certificate checking