'Fetch the certificate information.'

def update(self):

    try:
        ctx = ssl.create_default_context()
        sock = ctx.wrap_socket(socket.socket(), server_hostname=self.server_name)
        sock.settimeout(TIMEOUT)
        sock.connect((self.server_name, self.server_port))
    except socket.gaierror:
        _LOGGER.error('Cannot    resolve    hostname:    %s', self.server_name)
        return
    except socket.timeout:
        _LOGGER.error('Connection    timeout    with    server:    %s', self.server_name)
        return
    except OSError:
        _LOGGER.error('Cannot    connect    to    %s', self.server_name)
        return
    try:
        cert = sock.getpeercert()
    except OSError:
        _LOGGER.error('Cannot    fetch    certificate    from    %s', self.server_name)
        return
    ts_seconds = ssl.cert_time_to_seconds(cert['notAfter'])
    timestamp = datetime.datetime.fromtimestamp(ts_seconds)
    expiry = (timestamp - datetime.datetime.today())
    self._state = expiry.days
