':return: The remote peer certificate in a tuple'

def getpeercert(self, binary_form=False):

    x509 = self.ssl_conn.get_peer_certificate()
    if (not x509):
        raise ssl.SSLError('No    peer    certificate')
    if binary_form:
        return OpenSSL.crypto.dump_certificate(OpenSSL.crypto.FILETYPE_ASN1, x509)
    dns_name = []
    general_names = SubjectAltName()
    for i in range(x509.get_extension_count()):
        ext = x509.get_extension(i)
        ext_name = ext.get_short_name()
        if (ext_name != 'subjectAltName'):
            continue
        ext_dat = ext.get_data()
        decoded_dat = der_decoder(ext_dat, asn1Spec=general_names)
        for name in decoded_dat:
            if (not isinstance(name, SubjectAltName)):
                continue
            for entry in range(len(name)):
                component = name.getComponentByPosition(entry)
                if (component.getName() != 'dNSName'):
                    continue
                dns_name.append(('DNS', str(component.getComponent())))
    return {'subject': ((('commonName', x509.get_subject().CN),),), 'subjectAltName': dns_name}
