I believe that, by default, the HTTPS URL classes closely follow the rules laid out for checking server identity in section 3.1 of RFC 2818. I believe the error message you recieve indicates those identity checks fail. In general, if you specify a URL of "https://www.server.net", then the certificate sent back from that server should contain a special field called the "Subject Alternative Name", and furthermore the value of this field should be
www.server.net. In lieu of this, it may contain
www.server.net in one of the CN fields of the subject name. But please see RFC 2818 for the actual rules. If neither of these is true, I think you receive the error you got.
To see if this is indeed the problem, you can temporarily disable the hostname check by using a custom hostname verifier that always returns true.
NOTE: this is just for testing, don't do this in your real application! Here is a small example showing this: