mirror of
https://github.com/mozilla/cipherscan.git
synced 2024-11-25 07:23:41 +01:00
Changes analyze.py to be compatible with python3
This commit is contained in:
parent
b0548dff8e
commit
acfae638a3
12
analyze.py
12
analyze.py
@ -7,11 +7,17 @@
|
|||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import sys, os, json, subprocess, logging, argparse, platform, urllib2, re
|
import sys, os, json, subprocess, logging, argparse, platform, re
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
|
||||||
|
try:
|
||||||
|
from urllib2 import urlopen, URLError
|
||||||
|
except ModuleNotFoundError:
|
||||||
|
from urllib.request import urlopen
|
||||||
|
from urllib.error import URLError
|
||||||
|
|
||||||
def str_compat(data):
|
def str_compat(data):
|
||||||
if sys.version_info >= (3,0):
|
if sys.version_info >= (3,0):
|
||||||
data = str(data, 'utf-8')
|
data = str(data, 'utf-8')
|
||||||
@ -400,10 +406,10 @@ def build_ciphers_lists():
|
|||||||
sstlsurl = "https://statics.tls.security.mozilla.org/server-side-tls-conf.json"
|
sstlsurl = "https://statics.tls.security.mozilla.org/server-side-tls-conf.json"
|
||||||
conf = dict()
|
conf = dict()
|
||||||
try:
|
try:
|
||||||
raw = urllib2.urlopen(sstlsurl).read()
|
raw = urlopen(sstlsurl).read()
|
||||||
conf = json.loads(raw)
|
conf = json.loads(raw)
|
||||||
logging.debug('retrieving online server side tls recommendations from %s' % sstlsurl)
|
logging.debug('retrieving online server side tls recommendations from %s' % sstlsurl)
|
||||||
except urllib2.URLError:
|
except URLError:
|
||||||
with open('server-side-tls-conf.json', 'r') as f:
|
with open('server-side-tls-conf.json', 'r') as f:
|
||||||
conf = json.load(f)
|
conf = json.load(f)
|
||||||
logging.debug('Error connecting to %s; using local archive of server side tls recommendations' % sstlsurl)
|
logging.debug('Error connecting to %s; using local archive of server side tls recommendations' % sstlsurl)
|
||||||
|
Loading…
Reference in New Issue
Block a user