예제 #1
0
파일: sslverify.py 프로젝트: tefra/txsuds
    def _identityVerifyingInfoCallback(self, connection, where, ret):
        """
        Override the base implementation to provide better hostname verification.

        @param connection: the connection which is handshaking.
        @type connection: L{OpenSSL.SSL.Connection}

        @param where: flags indicating progress through a TLS handshake.
        @type where: L{int}

        @param ret: ignored
        @type ret:  ignored
        """
        if where & SSL_CB_HANDSHAKE_START:
            _maybeSetHostNameIndication(connection, self._hostnameBytes)
        elif where & SSL_CB_HANDSHAKE_DONE:
            if self._ctx.get_verify_mode() != SSL.VERIFY_NONE:
                try:
                    peer_cert = Certificate(connection.get_peer_certificate())
                    _matchHostname(peer_cert, self._hostname)
                except CertMatchError as ex:
                    log.error(str(ex))
                    f = Failure()
                    transport = connection.get_app_data()
                    transport.failVerification(f)
예제 #2
0
파일: tls.py 프로젝트: zwpaper/scrapy
 def _identityVerifyingInfoCallback(self, connection, where, ret):
     if where & SSL_CB_HANDSHAKE_START:
         _maybeSetHostNameIndication(connection, self._hostnameBytes)
     elif where & SSL_CB_HANDSHAKE_DONE:
         try:
             verifyHostname(connection, self._hostnameASCII)
         except VerificationError as e:
             logger.warning(e)
예제 #3
0
파일: tls.py 프로젝트: 447327642/scrapy
 def _identityVerifyingInfoCallback(self, connection, where, ret):
     if where & SSL_CB_HANDSHAKE_START:
         _maybeSetHostNameIndication(connection, self._hostnameBytes)
     elif where & SSL_CB_HANDSHAKE_DONE:
         try:
             verifyHostname(connection, self._hostnameASCII)
         except VerificationError as e:
             logger.warning(e)
예제 #4
0
 def _identityVerifyingInfoCallback(self, connection, where, ret):
     if where & SSL_CB_HANDSHAKE_START:
         _maybeSetHostNameIndication(connection, self._hostnameBytes)
     elif where & SSL_CB_HANDSHAKE_DONE:
         try:
             verifyHostname(connection, self._hostnameASCII)
         except VerificationError as e:
             logger.warning(
                 'Remote certificate is not valid for hostname "{}"; {}'
                 .format(self._hostnameASCII, e))
예제 #5
0
 def _identityVerifyingInfoCallback(self, connection, where, ret):
     if where & SSL_CB_HANDSHAKE_START:
         _maybeSetHostNameIndication(connection, self._hostnameBytes)
     elif where & SSL_CB_HANDSHAKE_DONE:
         try:
             verifyHostname(connection, self._hostnameASCII)
         except VerificationError:
             f = Failure()
             transport = connection.get_app_data()
             transport.failVerification(f)
예제 #6
0
파일: tls.py 프로젝트: 821760408-sp/scrapy
 def _identityVerifyingInfoCallback(self, connection, where, ret):
     if where & SSL_CB_HANDSHAKE_START:
         _maybeSetHostNameIndication(connection, self._hostnameBytes)
     elif where & SSL_CB_HANDSHAKE_DONE:
         try:
             verifyHostname(connection, self._hostnameASCII)
         except VerificationError as e:
             logger.warning(
                 'Remote certificate is not valid for hostname "{}"; {}'.format(
                     self._hostnameASCII, e))
예제 #7
0
    def _identityVerifyingInfoCallback(self, connection, where, ret):
        if where & SSL_CB_HANDSHAKE_START:
            _maybeSetHostNameIndication(connection, self._hostnameBytes)
        elif where & SSL_CB_HANDSHAKE_DONE:
            try:
                verifyHostname(connection, self._hostnameASCII)
            except VerificationError as e:
                log.warn(
                    'Remote certificate is not valid for hostname "{}"; {}'.
                    format(self._hostnameASCII, e))

            except ValueError as e:
                log.warn('Ignoring error while verifying certificate '
                         'from host "{}" (exception: {})'.format(
                             self._hostnameASCII, repr(e)))
예제 #8
0
    def _identityVerifyingInfoCallback(self, connection, where, ret):
        if where & SSL_CB_HANDSHAKE_START:
            _maybeSetHostNameIndication(connection, self._hostnameBytes)
        elif where & SSL_CB_HANDSHAKE_DONE:
            try:
                verifyHostname(connection, self._hostnameASCII)
            except VerificationError as e:
                log.warn(
                    'Remote certificate is not valid for hostname "{}"; {}'.format(
                        self._hostnameASCII, e))

            except ValueError as e:
                log.warn(
                    'Ignoring error while verifying certificate '
                    'from host "{}" (exception: {})'.format(
                        self._hostnameASCII, repr(e)))