#!/usr/bin/env python

# Loads JSON data from:
# https://atlas.ripe.net/measurements/3196765/
#
# Iterate results to filter out errors

import json
import urllib
import OpenSSL

# URL of measurement to examine
url = "https://atlas.ripe.net/api/v2/measurements/3196765/results?start=1451433600&stop=1451519999&format=json"

# Pull in the data from the server
response = urllib.urlopen(url)

# Load the JSON
data = json.loads(response.read())


for index in range(len(data)):        # Iterate thru results
  if data[index].has_key("dst_addr"):   # If result has a dst_addr
    print data[index]["dst_addr"]
    if data[index].has_key("cert"):     # If result has a cert
      for certindex in range(len(data[index]["cert"])):   # iterate thru certs
        # print cert components
        cert = data[index]["cert"][certindex]
        x509 = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_PEM, cert)
        print x509.get_subject().get_components()

@@ -913,16 +913,32 @@
    print
+ %22  CertData: %22,
  x509.ge
@@ -966,8 +966,96 @@
 nents()%0A
+%09print %22  SHA1:     %22, x509.digest(%22sha1%22)%0A%09print %22  SHA256:   %22, x509.digest(%22sha256%22)%0A

add more cert data (sha1/256 FP)