Skip to content

Instantly share code, notes, and snippets.

@dadrian
Created May 8, 2016 20:37
Show Gist options
  • Save dadrian/7995e0faa23e89d5ccba85f90afcb2d8 to your computer and use it in GitHub Desktop.
Save dadrian/7995e0faa23e89d5ccba85f90afcb2d8 to your computer and use it in GitHub Desktop.
Download all trusted NSS intermediates from Censys as PEM's (ignores roots)
from censys.certificates import CensysCertificates
import base64
query = "current_valid_nss: true AND parsed.extensions.basic_constraints.is_ca: true AND NOT current_in_nss: true"
fields = ["raw"]
def split(input, size):
for start in range(0, len(input), size):
yield input[start:start+size]
for idx, cert in enumerate(CensysCertificates().search(query, fields)):
try:
encoded = cert.get("raw")[0]
total = len(encoded)
print '-----BEGIN CERTIFICATE-----'
for line in split(encoded, 64):
print line
print '-----END CERTIFICATE-----'
except Exception as e:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment