Certificates fixes for autodiscovery

This was developed originally in 3.4 but it must be released in 3.5