Full error message reported is:

Metadata contains a reference that cannot be resolved:
The underlying connection was closed. Could not establish trust relationship for the SSL/TLS secure channel.
The remote certificate is invalid according to the validation procedure.

This is known to occur when accessing a secure WSDL and the server certificate is not trusted by .Net Framework, for example, when using self signed certificates.

If you paste the URL of the WSDL into Internet Explorer you should see the certificate warning "The certificate cannot be verified up to a trusted certification authority".  Internet Explorer and .Net Framework share the same certificate store so you can simply import the corresponding Certification Authority (CA) certificate into the Trusted Root Certificate Authorities store using Internet Explorer:

  • Open Internet Explorer
  • Select TOOLS | INTERNET OPTIONS | CONTENT tab | CERTIFICATES
  • Select the Trusted Root Certificate Authorities tab
  • Select IMPORT
  • Select NEXT
  • Select BROWSE
  • Browse to the CA certificate on your disk
  • Ensure that the Place all certificates in the following store is selected and set to Trusted Root Certificate Authorities
  • SELECT NEXT
  • SELECT FINISH
  • SELECT CLOSE