def _get_subject_public_key(cert):
        """
        Returns the SubjectPublicKey asn.1 field of the SubjectPublicKeyInfo
        field of the server's certificate. This is used in the server
        verification steps to thwart MitM attacks.

        :param cert: X509 certificate from pyOpenSSL .get_peer_certificate()
        :return: byte string of the asn.1 DER encoded SubjectPublicKey field
        """
        public_key = cert.get_pubkey()
        cryptographic_key = public_key.to_cryptography_key()
        subject_public_key = cryptographic_key.public_bytes(Encoding.DER,
                                                            PublicFormat.PKCS1)
        return subject_public_key