Ejemplo n.º 1
0
	print("usage: %s <service-id> <notary-list-file> [text|xml]" % sys.argv[0])
	exit(1)

output_type = "text"
if len(sys.argv) == 4: 
	output_type = sys.argv[3]

sid = sys.argv[1]
server_list = parse_http_notary_list(sys.argv[2]) 

for s in server_list: 
	try:
		s["results"] = None
		server = s["host"].split(":")[0]
		port = s["host"].split(":")[1]
		code, xml_text = fetch_notary_xml(server,int(port), sid)
		if code == 404: 
			pass
		if code != 200: 
			print("'%s' returned error code: %s" % (s["host"],code))
		elif not verify_notary_signature(sid, xml_text, s["public_key"]):
			print("Signature from '%s' failed, ignoring results" % s["host"])
		else: 
			# results are good
			s["results"] = xml_text
			
	except Exception, e:
		print("Exception contacting notary server:")
		traceback.print_exc(e)

if output_type == "text":
Ejemplo n.º 2
0
import sys
import traceback
from client_common import verify_notary_signature, notary_reply_as_text, fetch_notary_xml

if len(sys.argv) != 4 and len(sys.argv) != 5:
    print "usage: %s <service-id> <notary-server> <notary-port> [notary-pubkey]" % sys.argv[
        0]
    exit(1)

notary_pub_key = None
if len(sys.argv) == 5:
    notary_pub_key_file = sys.argv[4]
    notary_pub_key = open(notary_pub_key_file, 'r').read()

try:
    code, xml_text = fetch_notary_xml(sys.argv[2], int(sys.argv[3]),
                                      sys.argv[1])
    if code == 404:
        print "Notary has no results"
    elif code != 200:
        print "Notary server returned error code: %s" % code
except Exception, e:
    print "Exception contacting notary server:"
    traceback.print_exc(e)
    exit(1)

print 50 * "-"
print "XML Response:"
print xml_text

print 50 * "-"
parser.add_argument('service_id', default=DEFAULT_SERVER,
			help="A remote service of the form 'hostname:port,servicetype'. Use servicetype '1' for SSH or '2' for SSL.")
# don't use type=FileType for the key because we don't want argparse
# to try opening it before the program runs.
# this module should be callable without using any key at all.
parser.add_argument('--notary_pubkey', '--key', '-k', default=DEFAULT_KEYFILE, metavar='KEYFILE',
			help="File containing the notary's public key. If supplied the response signature from the notary will be verified. Default: \'%(default)s\'.")
parser.add_argument('--notary-server', '--server', '-s', default=DEFAULT_SERVER, metavar='SERVER',
			help="Notary server to contact. Default: \'%(default)s\'.")
parser.add_argument('--notary_port', '--port', '-p', type=int, default=DEFAULT_PORT, metavar='PORT',
			help="Port to contact the server on. Default: \'%(default)s\'.")

args = parser.parse_args()

try: 
	code, xml_text = fetch_notary_xml(args.notary_server, args.notary_port, args.service_id)
	if code == 404: 
		print "Notary has no results for '%s'." % args.service_id
	elif code != 200: 
		print "Notary server returned error code: %s" % code
except Exception, e:
	print "Exception contacting notary server:" 
	traceback.print_exc(e)
	exit(1) 

print 50 * "-"
print "XML Response:" 
print xml_text

print 50 * "-"
Ejemplo n.º 4
0
                    default=DEFAULT_SERVER,
                    metavar='SERVER',
                    help="Notary server to contact. Default: \'%(default)s\'.")
parser.add_argument(
    '--notary_port',
    '--port',
    '-p',
    type=int,
    default=DEFAULT_PORT,
    metavar='PORT',
    help="Port to contact the server on. Default: \'%(default)s\'.")

args = parser.parse_args()

try:
    code, xml_text = fetch_notary_xml(args.notary_server, args.notary_port,
                                      args.service_id)
    if code == 404:
        print "Notary has no results for '%s'." % args.service_id
    elif code != 200:
        print "Notary server returned error code: %s" % code
except Exception, e:
    print "Exception contacting notary server:"
    traceback.print_exc(e)
    exit(1)

print 50 * "-"
print "XML Response:"
print xml_text

print 50 * "-"
import sys
import traceback  
from client_common import verify_notary_signature, notary_reply_as_text,fetch_notary_xml 

if len(sys.argv) != 4 and len(sys.argv) != 5: 
	print "usage: %s <service-id> <notary-server> <notary-port> [notary-pubkey]" % sys.argv[0]
	exit(1)  


notary_pub_key = None
if len(sys.argv) == 5: 
	notary_pub_key_file = sys.argv[4] 
	notary_pub_key = open(notary_pub_key_file,'r').read() 

try: 
	code, xml_text = fetch_notary_xml(sys.argv[2],int(sys.argv[3]), sys.argv[1])
	if code == 404: 
		print "Notary has no results"
	elif code != 200: 
		print "Notary server returned error code: %s" % code
except Exception, e:
	print "Exception contacting notary server:" 
	traceback.print_exc(e)
	exit(1) 

print 50 * "-"
print "XML Response:" 
print xml_text

print 50 * "-"
Ejemplo n.º 6
0
#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see <http://www.gnu.org/licenses/>.

import time
import sys
import traceback
from client_common import verify_notary_signature, fetch_notary_xml, parse_http_notary_list
from generate_svg import get_svg_graph

if len(sys.argv) != 4:
    print "usage: %s <service-id> <notary-list-file> <len-days>" % sys.argv[0]
    exit(1)

sid = sys.argv[1]
server_list = parse_http_notary_list(sys.argv[2])

for s in server_list:
    try:
        s["results"] = None
        server = s["host"].split(":")[0]
        port = s["host"].split(":")[1]
        code, xml_text = fetch_notary_xml(server, int(port), sid)
        if code == 200 and verify_notary_signature(sid, xml_text,
                                                   s["public_key"]):
            s["results"] = xml_text

    except Exception, e:
        pass

print get_svg_graph(sid, server_list, int(sys.argv[3]), time.time())