TAXIIProject / libtaxii

A Python library for handling TAXII Messages invoking TAXII Services.
http://libtaxii.readthedocs.org/
BSD 3-Clause "New" or "Revised" License
70 stars 42 forks source link

libtaxii client examples with *current* services? #210

Closed olyerickson closed 8 years ago

olyerickson commented 8 years ago

When testing the following example client code against the MITRE test service we see errors

The code:

import libtaxii as t
import libtaxii.messages_11 as tm11
import libtaxii.clients as tc
from libtaxii.common import generate_message_id
from libtaxii.constants import *
from dateutil.tz import tzutc

client = tc.HttpClient()
client.set_use_https(True)
client.set_auth_type(tc.HttpClient.AUTH_BASIC)
client.set_auth_credentials({'username': 'MyUsername', 'password': 'MyPassword'})

discovery_request = tm11.DiscoveryRequest(generate_message_id())
discovery_xml = discovery_request.to_xml(pretty_print=True)

http_resp = client.call_taxii_service2('taxiitest.mitre.org', '/services/discovery/', VID_TAXII_XML_11, discovery_xml)
taxii_message = t.get_message_from_http_response(http_resp, discovery_request.message_id)
print taxii_message.to_xml(pretty_print=True)

The error...

Traceback (most recent call last):
  File "taxii_test_mitre.py", line 16, in <module>
    http_resp = client.call_taxii_service2('taxiitest.mitre.org', '/services/discovery/', VID_TAXII_XML_11, discovery_xml)
  File "/usr/local/lib/python2.7/dist-packages/libtaxii/clients.py", line 343, in call_taxii_service2
    response = urllib.request.urlopen(req)
  File "/usr/lib/python2.7/urllib2.py", line 127, in urlopen
    return _opener.open(url, data, timeout)
  File "/usr/lib/python2.7/urllib2.py", line 404, in open
    response = self._open(req, data)
  File "/usr/lib/python2.7/urllib2.py", line 422, in _open
    '_open', req)
  File "/usr/lib/python2.7/urllib2.py", line 382, in _call_chain
    result = func(*args)
  File "/usr/local/lib/python2.7/dist-packages/libtaxii/clients.py", line 371, in https_open
    return self.do_open(self.get_connection, req)
  File "/usr/lib/python2.7/urllib2.py", line 1184, in do_open
    raise URLError(err)
urllib2.URLError: <urlopen error [Errno -2] Name or service not known>
gtback commented 8 years ago

Thanks, @olyerickson . I need to figure out what happened with that server.

gtback commented 8 years ago

taxiitest.mitre.org is no longer active. hailataxii.com provides most (but not all) functionality we were demonstrating with the examples, so @clenk updated the examples to use that instead (in #211). If you know of other public TAXII servers we can use, let us know. Thanks again, @olyerickson.