def _pref_ciphersuite(self, target, ssl_version):
        """
        Initiates a SSL handshake with the server, using the SSL version and cipher
        suite specified.
        """
        ssl_ctx = SSL_CTX.SSL_CTX(ssl_version)
        ssl_ctx.set_verify(constants.SSL_VERIFY_NONE)
        # ssl_connect can be an HTTPS connection or an SMTP STARTTLS connection
        ssl_connect = SSLyzeSSLConnection(self._shared_settings, target,ssl_ctx,
                                          hello_workaround=True)
        
        try: # Perform the SSL handshake
            ssl_connect.connect()

            ssl_cipher = ssl_connect._ssl.get_current_cipher()
            if 'ADH' in ssl_cipher or 'AECDH' in ssl_cipher:
                keysize = 'Anon' # Anonymous, let s not care about the key size
            else:
                keysize = str(ssl_connect._ssl.get_current_cipher_bits())+' bits'
                
            status_msg = ssl_connect.post_handshake_check()
            return ('preferredCipherSuite', ssl_cipher, keysize, status_msg)
        
        except:
            return None
    
        finally:
            ssl_connect.close()
            
        return
Пример #2
0
    def _pref_ciphersuite(self, target, ssl_version):
        """
        Initiates a SSL handshake with the server, using the SSL version and cipher
        suite specified.
        """
        ssl_ctx = SSL_CTX.SSL_CTX(ssl_version)
        ssl_ctx.set_verify(constants.SSL_VERIFY_NONE)
        # ssl_connect can be an HTTPS connection or an SMTP STARTTLS connection
        ssl_connect = SSLyzeSSLConnection(self._shared_settings,
                                          target,
                                          ssl_ctx,
                                          hello_workaround=True)

        try:  # Perform the SSL handshake
            ssl_connect.connect()

            ssl_cipher = ssl_connect._ssl.get_current_cipher()
            if 'ADH' in ssl_cipher or 'AECDH' in ssl_cipher:
                keysize = 'Anon'  # Anonymous, let s not care about the key size
            else:
                keysize = str(
                    ssl_connect._ssl.get_current_cipher_bits()) + ' bits'

            status_msg = ssl_connect.post_handshake_check()
            return ('preferredCipherSuite', ssl_cipher, keysize, status_msg)

        except:
            return None

        finally:
            ssl_connect.close()

        return