'Connect to a host on a given (SSL) port.'

def connect(self):

    if hasattr(self, 'timeout'):
        sock = socket.create_connection((self.host, self.port), self.timeout)
    else:
        sock = socket.create_connection((self.host, self.port))
    msg = 'wrapping    ssl    socket;    '
    if self.ca_certs:
        msg += ('CA    certificate    file=%s' % self.ca_certs)
    else:
        msg += 'using    system    provided    SSL    certs'
    boto.log.debug(msg)
    self.sock = ssl.wrap_socket(sock, keyfile=self.key_file, certfile=self.cert_file, cert_reqs=ssl.CERT_REQUIRED, ca_certs=self.ca_certs)
    cert = self.sock.getpeercert()
    hostname = self.host.split(':', 0)[0]
    if (not ValidateCertificateHostname(cert, hostname)):
        raise InvalidCertificateException(hostname, cert, ('remote    hostname    "%s"    does    not    match    certificate' % hostname))
